Skip to content

Commit

Permalink
Fixes line blame disappearing after closing large dirty editor
Browse files Browse the repository at this point in the history
Fixes #3066.
  • Loading branch information
gluxon committed Dec 20, 2023
1 parent b33570a commit 67ac10e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
12 changes: 12 additions & 0 deletions src/trackers/gitLineTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ export class GitLineTracker extends LineTracker<GitLineState> {
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<GitLineTracker['onBlameStateChanged']>({
args: {
0: e => `editor/doc=${e.editor.document.uri.toString(true)}, blameable=${e.blameable}`,
Expand Down
7 changes: 7 additions & 0 deletions src/trackers/lineTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class LineTracker<T> implements Disposable {
this._selections = toLineSelections(editor?.selections);

this.notifyLinesChanged('editor');
this.onActiveEditorChanged?.();
}

private onTextEditorSelectionChanged(e: TextEditorSelectionChangeEvent) {
Expand Down Expand Up @@ -197,6 +198,12 @@ export class LineTracker<T> 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);
}
Expand Down

0 comments on commit 67ac10e

Please sign in to comment.