From 67ac10e9671099961d3c36764eb005d29fb13cb7 Mon Sep 17 00:00:00 2001 From: Brandon Cheng Date: Wed, 20 Dec 2023 00:16:39 -0500 Subject: [PATCH] Fixes line blame disappearing after closing large dirty editor Fixes #3066. --- CHANGELOG.md | 1 + README.md | 1 + src/trackers/gitLineTracker.ts | 12 ++++++++++++ src/trackers/lineTracker.ts | 7 +++++++ 4 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1dd674fd50d5..18d5bdb1b0230 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Fixed - Fixes [#2926](https://github.com/gitkraken/vscode-gitlens/issues/2926) in more cases - "Open File at Revision" has incorrect editor label if revision contains path separator — thanks to [PR #3060](https://github.com/gitkraken/vscode-gitlens/issues/3060) by Ian Chamberlain ([@ian-h-chamberlain](https://github.com/ian-h-chamberlain) +- Fixes [#3066](https://github.com/gitkraken/vscode-gitlens/issues/3066) - Editing a large file and switching away to another file without saving cause current line blame to disappear; thanks to [PR #3067](https://github.com/gitkraken/vscode-gitlens/pulls/3067) by Brandon Cheng ([@gluxon](https://github.com/gluxon)). ## [14.6.1] - 2023-12-14 diff --git a/README.md b/README.md index 003dc52035c41..6106758ca50c3 100644 --- a/README.md +++ b/README.md @@ -427,6 +427,7 @@ A big thanks to the people that have contributed to this project πŸ™β€οΈ: - WofWca ([@WofWca](https://github.com/WofWca)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=WofWca) - 不见月 ([@nooooooom](https://github.com/nooooooom)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=nooooooom) - Ian Chamberlain ([@ian-h-chamberlain](https://github.com/ian-h-chamberlain)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=ian-h-chamberlain) +- Brandon Cheng ([@gluxon](https://github.com/gluxon)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=gluxon)` Also special thanks to the people that have provided support, testing, brainstorming, etc: diff --git a/src/trackers/gitLineTracker.ts b/src/trackers/gitLineTracker.ts index 945117891bda7..bbdcd36cc2823 100644 --- a/src/trackers/gitLineTracker.ts +++ b/src/trackers/gitLineTracker.ts @@ -58,6 +58,18 @@ export class GitLineTracker extends LineTracker { this._subscriptionOnlyWhenActive = undefined; } + protected override onActiveEditorChanged() { + // The GitLineTracker is suspended for performance while users have + // dirty changes in a large editor with lines exceeding the + // advanced.blame.sizeThresholdAfterEdit config. + // + // We'll need to resume if the active editor has changed (since the + // suspension was for the previous editor). Otherwise the line tracker + // would stay suspended after navigating away from the large dirty + // document. + this.resume(); + } + @debug({ args: { 0: e => `editor/doc=${e.editor.document.uri.toString(true)}, blameable=${e.blameable}`, diff --git a/src/trackers/lineTracker.ts b/src/trackers/lineTracker.ts index 029f24b0d794b..1f028bfeff741 100644 --- a/src/trackers/lineTracker.ts +++ b/src/trackers/lineTracker.ts @@ -44,6 +44,7 @@ export class LineTracker implements Disposable { this._selections = toLineSelections(editor?.selections); this.notifyLinesChanged('editor'); + this.onActiveEditorChanged?.(); } private onTextEditorSelectionChanged(e: TextEditorSelectionChangeEvent) { @@ -197,6 +198,12 @@ export class LineTracker implements Disposable { this.notifyLinesChanged('editor'); } + /** + * Called after the active editor is changed and line tracker state has been + * updated for it. + */ + protected onActiveEditorChanged?(): void; + protected fireLinesChanged(e: LinesChangeEvent) { this._onDidChangeActiveLines.fire(e); }