diff --git a/package.json b/package.json index 23aa6fd..fe8696b 100644 --- a/package.json +++ b/package.json @@ -5971,12 +5971,12 @@ }, { "command": "gitlens.views.fileHistory.setEditorFollowingOn", - "when": "view =~ /^gitlens\\.views\\.fileHistory/ && !gitlens:views:fileHistory:editorFollowing", + "when": "view =~ /^gitlens\\.views\\.fileHistory/ && gitlens:views:fileHistory:canPin && !gitlens:views:fileHistory:editorFollowing", "group": "navigation@10" }, { "command": "gitlens.views.fileHistory.setEditorFollowingOff", - "when": "view =~ /^gitlens\\.views\\.fileHistory/ && gitlens:views:fileHistory:editorFollowing", + "when": "view =~ /^gitlens\\.views\\.fileHistory/ && gitlens:views:fileHistory:canPin && gitlens:views:fileHistory:editorFollowing", "group": "navigation@10" }, { diff --git a/src/constants.ts b/src/constants.ts index 4021f65..b6c1591 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -44,6 +44,7 @@ export enum ContextKeys { ViewsCanCompare = 'gitlens:views:canCompare', ViewsCanCompareFile = 'gitlens:views:canCompare:file', ViewsCommitsMyCommitsOnly = 'gitlens:views:commits:myCommitsOnly', + ViewsFileHistoryCanPin = 'gitlens:views:fileHistory:canPin', ViewsFileHistoryCursorFollowing = 'gitlens:views:fileHistory:cursorFollowing', ViewsFileHistoryEditorFollowing = 'gitlens:views:fileHistory:editorFollowing', ViewsLineHistoryEditorFollowing = 'gitlens:views:lineHistory:editorFollowing', diff --git a/src/views/fileHistoryView.ts b/src/views/fileHistoryView.ts index 3c7f73b..7fc0585 100644 --- a/src/views/fileHistoryView.ts +++ b/src/views/fileHistoryView.ts @@ -101,14 +101,17 @@ export class FileHistoryView extends ViewBase { private _base: string | undefined; private _child: FileHistoryNode | undefined; - private _fileUri: GitUri | undefined; protected splatted = true; constructor(view: FileHistoryView) { @@ -39,27 +38,29 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode { if (this._child == null) { - if (this._fileUri == null && this.uri === unknownGitUri) { + if (!this.hasUri) { this.view.description = undefined; - return [ - new MessageNode( - this.view, - this, - 'There are no editors open that can provide file history information.', - ), - ]; + this.view.message = 'There are no editors open that can provide file history information.'; + return []; } - const uri = this._fileUri ?? this.uri; - const commitish: GitCommitish = { ...uri, repoPath: uri.repoPath!, sha: this._base ?? uri.sha }; - const fileUri = new GitUri(uri, commitish); + this.view.message = undefined; + + const commitish: GitCommitish = { + ...this.uri, + repoPath: this.uri.repoPath!, + sha: this._base ?? this.uri.sha, + }; + const fileUri = new GitUri(this.uri, commitish); let branch; if (!commitish.sha || commitish.sha === 'HEAD') { - branch = await Container.git.getBranch(uri.repoPath); + branch = await Container.git.getBranch(this.uri.repoPath); } else if (!GitRevision.isSha(commitish.sha)) { - [branch] = await Container.git.getBranches(uri.repoPath, { filter: b => b.name === commitish.sha }); + [branch] = await Container.git.getBranches(this.uri.repoPath, { + filter: b => b.name === commitish.sha, + }); } this._child = new FileHistoryNode(fileUri, this.view, this, branch); } @@ -80,6 +81,10 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode e.document?.uri.path === this.uri.path)) ) { return true; } - this._uri = unknownGitUri; + this.setUri(); this.resetChild(); - if (cc !== undefined) { + if (cc != null) { cc.exitDetails = `, uri=${Logger.toLoggable(this._uri)}`; } return false; } if (editor.document.uri.path === this.uri.path) { - if (cc !== undefined) { + if (cc != null) { cc.exitDetails = `, uri=${Logger.toLoggable(this._uri)}`; } return true; @@ -152,26 +157,26 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode { private _base: string | undefined; @@ -42,18 +42,15 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode { if (this._child == null) { - if (this.uri === unknownGitUri) { + if (!this.hasUri) { this.view.description = undefined; - return [ - new MessageNode( - this.view, - this, - 'There are no editors open that can provide line history information.', - ), - ]; + this.view.message = 'There are no editors open that can provide line history information.'; + return []; } + this.view.message = undefined; + const commitish: GitCommitish = { ...this.uri, repoPath: this.uri.repoPath!, @@ -90,6 +87,10 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode e.document?.uri.path === this.uri.path)) ) { return true; } - this._uri = unknownGitUri; + this.setUri(); this._editorContents = undefined; this._selection = undefined; this.resetChild(); - if (cc !== undefined) { + if (cc != null) { cc.exitDetails = `, uri=${Logger.toLoggable(this._uri)}`; } return false; @@ -158,10 +159,10 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode