Skip to content

Commit 8552c1f

Browse files
committed
Fixes blame context after save
1 parent 0f44a76 commit 8552c1f

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
88
### Changed
99
- Swaps out Moment.js for date-fns to improve blame annotation performance and to reduce the GitLen bundle size (saves ~400kb)
1010

11+
### Fixed
12+
- Fixes issue where the `Toggle File Blame Annotations` command (`gitlens.toggleFileBlame`) wasn't available after a file was saved
13+
1114
## [5.6.2] - 2017-10-11
1215
### Fixed
1316
- Fixes issue where `Open File` command failed for in many instances (for GitUri resources)

src/git/gitContextTracker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ export class GitContextTracker extends Disposable {
8181
// this._unsubscribeToDocumentChanges();
8282
// this.updateBlameability(false);
8383

84-
// TODO: Rework this once https://github.com/Microsoft/vscode/issues/27231 is released in v1.13
8584
// We have to defer because isDirty is not reliable inside this event
85+
// https://github.com/Microsoft/vscode/issues/27231
8686
setTimeout(async () => {
8787
let blameable = !e.document.isDirty;
8888
if (blameable) {
89-
blameable = await this.git.getBlameability(new GitUri(e.document.uri));
89+
blameable = await this.git.getBlameability(await GitUri.fromUri(e.document.uri, this.git));
9090
}
9191
this._updateBlameability(blameable);
9292
}, 1);
@@ -100,7 +100,7 @@ export class GitContextTracker extends Disposable {
100100

101101
let blameable = !e.isDirty;
102102
if (blameable) {
103-
blameable = await this.git.getBlameability(new GitUri(e.uri));
103+
blameable = await this.git.getBlameability(await GitUri.fromUri(e.uri, this.git));
104104
}
105105
this._updateBlameability(blameable);
106106
}

src/git/gitUri.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export class GitUri extends ((Uri as any) as UriEx) {
2121
constructor(uri?: Uri, commitOrRepoPath?: IGitCommitInfo | string) {
2222
if (uri === undefined) {
2323
super();
24+
2425
return;
2526
}
2627

@@ -36,7 +37,11 @@ export class GitUri extends ((Uri as any) as UriEx) {
3637
return;
3738
}
3839

39-
if (!commitOrRepoPath) return;
40+
if (commitOrRepoPath === undefined) {
41+
super(uri.scheme, uri.authority, uri.path, uri.query, uri.fragment);
42+
43+
return;
44+
}
4045

4146
if (typeof commitOrRepoPath === 'string') {
4247
super(uri.scheme, uri.authority, uri.path, uri.query, uri.fragment);

src/gitService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ export class GitService extends Disposable {
217217
if (!this.UseCaching) return;
218218
if (e.document.uri.scheme !== DocumentSchemes.File) return;
219219

220-
// TODO: Rework this once https://github.com/Microsoft/vscode/issues/27231 is released in v1.13
221220
// We have to defer because isDirty is not reliable inside this event
221+
// https://github.com/Microsoft/vscode/issues/27231
222222
setTimeout(() => {
223223
// If the document is dirty all is fine, we'll just wait for the save before clearing our cache
224224
if (e.document.isDirty) return;

0 commit comments

Comments
 (0)