Skip to content

Commit

Permalink
Fixes #3915 clears annotations on tab close
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Jan 8, 2025
1 parent 53e7cc0 commit 31e5067
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### Fixed

- Fixes [#3914](https://github.com/gitkraken/vscode-gitlens/issues/#3914) - Attempting to clear a file annotation on a split file w/o the annotation no-ops
- Fixes [#3911](https://github.com/gitkraken/vscode-gitlens/issues/#3911) - Avoid Home opening when first-install isn't reliable (e.g. GitPod)
- Fixes [#3888](https://github.com/gitkraken/vscode-gitlens/issues/#3888) - Graph hover should disappear when right-clicking a row
- Fixes [#3915](https://github.com/gitkraken/vscode-gitlens/issues/3915) - Closing a split editor with annotations causes the Clear Annotations button to get stuck
- Fixes [#3914](https://github.com/gitkraken/vscode-gitlens/issues/3914) - Attempting to clear a file annotation on a split file w/o the annotation no-ops
- Fixes [#3911](https://github.com/gitkraken/vscode-gitlens/issues/3911) - Avoid Home opening when first-install isn't reliable (e.g. GitPod)
- Fixes [#3888](https://github.com/gitkraken/vscode-gitlens/issues/3888) - Graph hover should disappear when right-clicking a row

## [16.1.1] - 2024-12-20

Expand All @@ -29,7 +30,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### Fixed

- Fixes [#3899](https://github.com/gitkraken/vscode-gitlens/issues/#3899) - custom autolinks not being detected
- Fixes [#3899](https://github.com/gitkraken/vscode-gitlens/issues/3899) - custom autolinks not being detected
- Fixes owner avatars from getting lost (progressively) on refresh of the _Home_ view
- Fixes launchpad status icon for 'waiting for review' state on _Home_
- Fixes missing _Delete Branch..._ command from branches on worktrees in the _Branches_ view
Expand Down
8 changes: 7 additions & 1 deletion src/annotations/annotationProvider.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { TextEditor, TextEditorDecorationType, TextEditorSelectionChangeEvent } from 'vscode';
import type { Tab, TextEditor, TextEditorDecorationType, TextEditorSelectionChangeEvent } from 'vscode';
import { Disposable, window } from 'vscode';
import type { FileAnnotationType } from '../config';
import type { AnnotationStatus } from '../constants';
import type { Container } from '../container';
import { Logger } from '../system/logger';
import type { Deferred } from '../system/promise';
import { defer } from '../system/promise';
import { getTabUri } from '../system/vscode/utils';
import type { TrackedGitDocument } from '../trackers/trackedDocument';
import type { Decoration } from './annotations';

Expand All @@ -23,6 +24,11 @@ export function getEditorCorrelationKey(editor: TextEditor | undefined): TextEdi
return `${editor?.document.uri.toString()}|${editor?.viewColumn ?? 0}`;
}

export function getEditorCorrelationKeyFromTab(tab: Tab): TextEditorCorrelationKey {
const uri = getTabUri(tab);
return `${uri?.toString()}|${tab.group.viewColumn}`;
}

export type DidChangeStatusCallback = (e: { editor?: TextEditor; status?: AnnotationStatus }) => void;

export abstract class AnnotationProviderBase<TContext extends AnnotationContext = AnnotationContext>
Expand Down
10 changes: 9 additions & 1 deletion src/annotations/fileAnnotationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {
ConfigurationChangeEvent,
Event,
Progress,
TabChangeEvent,
TextDocument,
TextEditor,
TextEditorDecorationType,
Expand Down Expand Up @@ -42,7 +43,7 @@ import type {
DocumentDirtyStateChangeEvent,
} from '../trackers/documentTracker';
import type { AnnotationContext, AnnotationProviderBase, TextEditorCorrelationKey } from './annotationProvider';
import { getEditorCorrelationKey } from './annotationProvider';
import { getEditorCorrelationKey, getEditorCorrelationKeyFromTab } from './annotationProvider';
import type { ChangesAnnotationContext } from './gutterChangesAnnotationProvider';

export const Decorations = {
Expand Down Expand Up @@ -227,6 +228,12 @@ export class FileAnnotationController implements Disposable {
}
}

private onTabsChanged(e: TabChangeEvent) {
for (const tab of e.closed) {
void this.clearCore(getEditorCorrelationKeyFromTab(tab));
}
}

private onTextDocumentClosed(document: TextDocument) {
if (!this.container.git.isTrackable(document.uri)) return;

Expand Down Expand Up @@ -688,6 +695,7 @@ export class FileAnnotationController implements Disposable {
window.onDidChangeActiveTextEditor(debounce(this.onActiveTextEditorChanged, 50), this),
window.onDidChangeTextEditorViewColumn(this.onTextEditorViewColumnChanged, this),
window.onDidChangeVisibleTextEditors(debounce(this.onVisibleTextEditorsChanged, 50), this),
window.tabGroups.onDidChangeTabs(this.onTabsChanged, this),
workspace.onDidCloseTextDocument(this.onTextDocumentClosed, this),
this.container.documentTracker.onDidChangeBlameState(this.onBlameStateChanged, this),
this.container.documentTracker.onDidChangeDirtyState(this.onDirtyStateChanged, this),
Expand Down

0 comments on commit 31e5067

Please sign in to comment.