Skip to content

Commit 31e5067

Browse files
committed
Fixes #3915 clears annotations on tab close
1 parent 53e7cc0 commit 31e5067

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

Diff for: CHANGELOG.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1313

1414
### Fixed
1515

16-
- 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
17-
- Fixes [#3911](https://github.com/gitkraken/vscode-gitlens/issues/#3911) - Avoid Home opening when first-install isn't reliable (e.g. GitPod)
18-
- Fixes [#3888](https://github.com/gitkraken/vscode-gitlens/issues/#3888) - Graph hover should disappear when right-clicking a row
16+
- Fixes [#3915](https://github.com/gitkraken/vscode-gitlens/issues/3915) - Closing a split editor with annotations causes the Clear Annotations button to get stuck
17+
- 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
18+
- Fixes [#3911](https://github.com/gitkraken/vscode-gitlens/issues/3911) - Avoid Home opening when first-install isn't reliable (e.g. GitPod)
19+
- Fixes [#3888](https://github.com/gitkraken/vscode-gitlens/issues/3888) - Graph hover should disappear when right-clicking a row
1920

2021
## [16.1.1] - 2024-12-20
2122

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

3031
### Fixed
3132

32-
- Fixes [#3899](https://github.com/gitkraken/vscode-gitlens/issues/#3899) - custom autolinks not being detected
33+
- Fixes [#3899](https://github.com/gitkraken/vscode-gitlens/issues/3899) - custom autolinks not being detected
3334
- Fixes owner avatars from getting lost (progressively) on refresh of the _Home_ view
3435
- Fixes launchpad status icon for 'waiting for review' state on _Home_
3536
- Fixes missing _Delete Branch..._ command from branches on worktrees in the _Branches_ view

Diff for: src/annotations/annotationProvider.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import type { TextEditor, TextEditorDecorationType, TextEditorSelectionChangeEvent } from 'vscode';
1+
import type { Tab, TextEditor, TextEditorDecorationType, TextEditorSelectionChangeEvent } from 'vscode';
22
import { Disposable, window } from 'vscode';
33
import type { FileAnnotationType } from '../config';
44
import type { AnnotationStatus } from '../constants';
55
import type { Container } from '../container';
66
import { Logger } from '../system/logger';
77
import type { Deferred } from '../system/promise';
88
import { defer } from '../system/promise';
9+
import { getTabUri } from '../system/vscode/utils';
910
import type { TrackedGitDocument } from '../trackers/trackedDocument';
1011
import type { Decoration } from './annotations';
1112

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

27+
export function getEditorCorrelationKeyFromTab(tab: Tab): TextEditorCorrelationKey {
28+
const uri = getTabUri(tab);
29+
return `${uri?.toString()}|${tab.group.viewColumn}`;
30+
}
31+
2632
export type DidChangeStatusCallback = (e: { editor?: TextEditor; status?: AnnotationStatus }) => void;
2733

2834
export abstract class AnnotationProviderBase<TContext extends AnnotationContext = AnnotationContext>

Diff for: src/annotations/fileAnnotationController.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type {
33
ConfigurationChangeEvent,
44
Event,
55
Progress,
6+
TabChangeEvent,
67
TextDocument,
78
TextEditor,
89
TextEditorDecorationType,
@@ -42,7 +43,7 @@ import type {
4243
DocumentDirtyStateChangeEvent,
4344
} from '../trackers/documentTracker';
4445
import type { AnnotationContext, AnnotationProviderBase, TextEditorCorrelationKey } from './annotationProvider';
45-
import { getEditorCorrelationKey } from './annotationProvider';
46+
import { getEditorCorrelationKey, getEditorCorrelationKeyFromTab } from './annotationProvider';
4647
import type { ChangesAnnotationContext } from './gutterChangesAnnotationProvider';
4748

4849
export const Decorations = {
@@ -227,6 +228,12 @@ export class FileAnnotationController implements Disposable {
227228
}
228229
}
229230

231+
private onTabsChanged(e: TabChangeEvent) {
232+
for (const tab of e.closed) {
233+
void this.clearCore(getEditorCorrelationKeyFromTab(tab));
234+
}
235+
}
236+
230237
private onTextDocumentClosed(document: TextDocument) {
231238
if (!this.container.git.isTrackable(document.uri)) return;
232239

@@ -688,6 +695,7 @@ export class FileAnnotationController implements Disposable {
688695
window.onDidChangeActiveTextEditor(debounce(this.onActiveTextEditorChanged, 50), this),
689696
window.onDidChangeTextEditorViewColumn(this.onTextEditorViewColumnChanged, this),
690697
window.onDidChangeVisibleTextEditors(debounce(this.onVisibleTextEditorsChanged, 50), this),
698+
window.tabGroups.onDidChangeTabs(this.onTabsChanged, this),
691699
workspace.onDidCloseTextDocument(this.onTextDocumentClosed, this),
692700
this.container.documentTracker.onDidChangeBlameState(this.onBlameStateChanged, this),
693701
this.container.documentTracker.onDidChangeDirtyState(this.onDirtyStateChanged, this),

0 commit comments

Comments
 (0)