Skip to content

Commit c2a352f

Browse files
committed
Fixes incorrectly setting isBlameable context
1 parent d22deb7 commit c2a352f

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1212
- Removes `Custom` from the `gitlens.codeLens.locations` setting as it wasn't really required
1313
- Removes properties (symbol `Property`) from being included in the `Blocks` option of the `gitlens.codeLens.locations` setting -- can be easily re-added by setting `"gitlens.codeLens.customLocationSymbols": [ "Property" ]` if desired
1414

15+
### Fixed
16+
- Fixes issue where `isBlameable` context could be set incorrectly leading to blame icon showing up on invalid documents
17+
1518
## [5.5.0] - 2017-10-09
1619
### Added
1720
- Adds a **quick-access** command bar to the bottom of the `details` hover annotations

src/annotations/annotationController.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,15 @@ export class AnnotationController extends Disposable {
325325
}
326326

327327
return window.withProgress({ location: ProgressLocation.Window }, async (progress: Progress<{ message: string }>) => {
328-
await setCommandContext(CommandContext.AnnotationStatus, AnnotationStatus.Computing);
328+
const active = editor === window.activeTextEditor;
329+
await setCommandContext(CommandContext.AnnotationStatus, active ? AnnotationStatus.Computing : undefined);
329330

330331
const computingAnnotations = this.showAnnotationsCore(currentProvider, editor, type, shaOrLine, progress);
331332
const result = await computingAnnotations;
332333

333-
await setCommandContext(CommandContext.AnnotationStatus, result ? AnnotationStatus.Computed : undefined);
334+
if (active) {
335+
await setCommandContext(CommandContext.AnnotationStatus, result ? AnnotationStatus.Computed : undefined);
336+
}
334337

335338
return computingAnnotations;
336339
});

src/git/gitContextTracker.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,26 @@ export class GitContextTracker extends Disposable {
8383

8484
// TODO: Rework this once https://github.com/Microsoft/vscode/issues/27231 is released in v1.13
8585
// We have to defer because isDirty is not reliable inside this event
86-
setTimeout(() => this._updateBlameability(!e.document.isDirty), 1);
86+
setTimeout(async () => {
87+
let blameable = !e.document.isDirty;
88+
if (blameable) {
89+
blameable = await this.git.getBlameability(new GitUri(e.document.uri));
90+
}
91+
this._updateBlameability(blameable);
92+
}, 1);
8793
}
8894

89-
private _onTextDocumentSaved(e: TextDocument) {
95+
private async _onTextDocumentSaved(e: TextDocument) {
9096
if (!TextDocumentComparer.equals(this._editor && this._editor.document, e)) return;
9197

9298
// Don't need to resubscribe as we aren't unsubscribing on document changes anymore
9399
// this._subscribeToDocumentChanges();
94-
this._updateBlameability(!e.isDirty);
100+
101+
let blameable = !e.isDirty;
102+
if (blameable) {
103+
blameable = await this.git.getBlameability(new GitUri(e.uri));
104+
}
105+
this._updateBlameability(blameable);
95106
}
96107

97108
private _subscribeToDocumentChanges() {

0 commit comments

Comments
 (0)