diff --git a/package.json b/package.json index 482e33c..baad1f6 100644 --- a/package.json +++ b/package.json @@ -2316,15 +2316,15 @@ "commandPalette": [ { "command": "gitlens.showRepositoriesView", - "when": "gitlens:enabled && gitlens:views:repositories" + "when": "gitlens:enabled && config.gitlens.views.repositories.enabled" }, { "command": "gitlens.showFileHistoryView", - "when": "gitlens:enabled && gitlens:views:fileHistory" + "when": "gitlens:enabled && config.gitlens.views.fileHistory.enabled" }, { "command": "gitlens.showLineHistoryView", - "when": "gitlens:enabled && gitlens:views:lineHistory" + "when": "gitlens:enabled && config.gitlens.views.lineHistory.enabled" }, { "command": "gitlens.showResultsView", @@ -3683,162 +3683,162 @@ { "command": "gitlens.toggleFileBlame", "key": "alt+b", - "when": "gitlens:keymap == alternate && editorTextFocus && gitlens:activeFileStatus =~ /blameable/" + "when": "config.gitlens.keymap == alternate && editorTextFocus && gitlens:activeFileStatus =~ /blameable/" }, { "command": "gitlens.toggleCodeLens", "key": "shift+alt+b", - "when": "gitlens:keymap == alternate && editorTextFocus && gitlens:enabled && gitlens:canToggleCodeLens" + "when": "config.gitlens.keymap == alternate && editorTextFocus && gitlens:enabled && gitlens:canToggleCodeLens" }, { "command": "gitlens.showLastQuickPick", "key": "alt+-", - "when": "gitlens:keymap == alternate && gitlens:enabled" + "when": "config.gitlens.keymap == alternate && gitlens:enabled" }, { "command": "gitlens.showCommitSearch", "key": "alt+/", - "when": "gitlens:keymap == alternate && gitlens:enabled" + "when": "config.gitlens.keymap == alternate && gitlens:enabled" }, { "command": "gitlens.showQuickFileHistory", "key": "alt+h", - "when": "gitlens:keymap == alternate && gitlens:enabled" + "when": "config.gitlens.keymap == alternate && gitlens:enabled" }, { "command": "gitlens.showQuickRepoHistory", "key": "shift+alt+h", - "when": "gitlens:keymap == alternate && gitlens:enabled" + "when": "config.gitlens.keymap == alternate && gitlens:enabled" }, { "command": "gitlens.showQuickRepoStatus", "key": "alt+s", - "when": "gitlens:keymap == alternate && gitlens:enabled" + "when": "config.gitlens.keymap == alternate && gitlens:enabled" }, { "command": "gitlens.showQuickCommitFileDetails", "key": "alt+c", - "when": "gitlens:keymap == alternate && editorTextFocus && gitlens:enabled" + "when": "config.gitlens.keymap == alternate && editorTextFocus && gitlens:enabled" }, { "command": "gitlens.diffWithNext", "key": "alt+.", - "when": "gitlens:keymap == alternate && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" + "when": "config.gitlens.keymap == alternate && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" }, { "command": "gitlens.diffLineWithPrevious", "key": "shift+alt+,", - "when": "gitlens:keymap == alternate && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" + "when": "config.gitlens.keymap == alternate && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" }, { "command": "gitlens.diffWithPrevious", "key": "alt+,", - "when": "gitlens:keymap == alternate && editorTextFocus && !isInDiffEditor && gitlens:activeFileStatus =~ /tracked/" + "when": "config.gitlens.keymap == alternate && editorTextFocus && !isInDiffEditor && gitlens:activeFileStatus =~ /tracked/" }, { "command": "gitlens.diffWithPreviousInDiff", "key": "alt+,", - "when": "gitlens:keymap == alternate && isInDiffEditor && gitlens:activeFileStatus =~ /tracked/" + "when": "config.gitlens.keymap == alternate && isInDiffEditor && gitlens:activeFileStatus =~ /tracked/" }, { "command": "gitlens.diffLineWithWorking", "key": "alt+w", - "when": "gitlens:keymap == alternate && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" + "when": "config.gitlens.keymap == alternate && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" }, { "command": "gitlens.diffWithWorking", "key": "shift+alt+w", - "when": "gitlens:keymap == alternate && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" + "when": "config.gitlens.keymap == alternate && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" }, { "command": "gitlens.toggleFileBlame", "key": "ctrl+shift+g b", "mac": "cmd+alt+g b", - "when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeFileStatus =~ /blameable/" + "when": "config.gitlens.keymap == chorded && editorTextFocus && gitlens:activeFileStatus =~ /blameable/" }, { "command": "gitlens.toggleCodeLens", "key": "ctrl+shift+g shift+b", "mac": "cmd+alt+g shift+b", - "when": "gitlens:keymap == chorded && editorTextFocus && gitlens:enabled && gitlens:canToggleCodeLens" + "when": "config.gitlens.keymap == chorded && editorTextFocus && gitlens:enabled && gitlens:canToggleCodeLens" }, { "command": "gitlens.showLastQuickPick", "key": "ctrl+shift+g -", "mac": "cmd+alt+g -", - "when": "gitlens:keymap == chorded && gitlens:enabled" + "when": "config.gitlens.keymap == chorded && gitlens:enabled" }, { "command": "gitlens.showCommitSearch", "key": "ctrl+shift+g /", "mac": "cmd+alt+g /", - "when": "gitlens:keymap == chorded && gitlens:enabled" + "when": "config.gitlens.keymap == chorded && gitlens:enabled" }, { "command": "gitlens.showQuickFileHistory", "key": "ctrl+shift+g h", "mac": "cmd+alt+g h", - "when": "gitlens:keymap == chorded && gitlens:enabled" + "when": "config.gitlens.keymap == chorded && gitlens:enabled" }, { "command": "gitlens.showQuickRepoHistory", "key": "ctrl+shift+g shift+h", "mac": "cmd+alt+g shift+h", - "when": "gitlens:keymap == chorded && gitlens:enabled" + "when": "config.gitlens.keymap == chorded && gitlens:enabled" }, { "command": "gitlens.showQuickRepoStatus", "key": "ctrl+shift+g s", "mac": "cmd+alt+g s", - "when": "gitlens:keymap == chorded && gitlens:enabled" + "when": "config.gitlens.keymap == chorded && gitlens:enabled" }, { "command": "gitlens.showQuickCommitFileDetails", "key": "ctrl+shift+g c", "mac": "cmd+alt+g c", - "when": "gitlens:keymap == chorded && editorTextFocus && gitlens:enabled" + "when": "config.gitlens.keymap == chorded && editorTextFocus && gitlens:enabled" }, { "command": "gitlens.diffWithNext", "key": "ctrl+shift+g .", "mac": "cmd+alt+g .", - "when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" + "when": "config.gitlens.keymap == chorded && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" }, { "command": "gitlens.diffLineWithPrevious", "key": "ctrl+shift+g shift+,", "mac": "cmd+alt+g shift+,", - "when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" + "when": "config.gitlens.keymap == chorded && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" }, { "command": "gitlens.diffWithPrevious", "key": "ctrl+shift+g ,", "mac": "cmd+alt+g ,", - "when": "gitlens:keymap == chorded && editorTextFocus && !isInDiffEditor && gitlens:activeFileStatus =~ /tracked/" + "when": "config.gitlens.keymap == chorded && editorTextFocus && !isInDiffEditor && gitlens:activeFileStatus =~ /tracked/" }, { "command": "gitlens.diffWithPreviousInDiff", "key": "ctrl+shift+g ,", "mac": "cmd+alt+g ,", - "when": "gitlens:keymap == chorded && isInDiffEditor && gitlens:activeFileStatus =~ /tracked/" + "when": "config.gitlens.keymap == chorded && isInDiffEditor && gitlens:activeFileStatus =~ /tracked/" }, { "command": "gitlens.diffLineWithWorking", "key": "ctrl+shift+g w", "mac": "cmd+alt+g w", - "when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" + "when": "config.gitlens.keymap == chorded && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" }, { "command": "gitlens.diffWithWorking", "key": "ctrl+shift+g shift+w", "mac": "cmd+alt+g shift+w", - "when": "gitlens:keymap == chorded && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" + "when": "config.gitlens.keymap == chorded && editorTextFocus && gitlens:activeFileStatus =~ /tracked/" }, { "command": "workbench.view.scm", "key": "ctrl+shift+g g", "mac": "ctrl+shift+g", - "when": "gitlens:keymap == chorded && gitlens:enabled" + "when": "config.gitlens.keymap == chorded && gitlens:enabled" } ], "viewsContainers": { @@ -3855,66 +3855,66 @@ { "id": "gitlens.views.repositories:gitlens", "name": "Repositories", - "when": "gitlens:enabled && gitlens:views:repositories == gitlens" + "when": "gitlens:enabled && config.gitlens.views.repositories.enabled && config.gitlens.views.repositories.location == gitlens" }, { "id": "gitlens.views.fileHistory:gitlens", "name": "File History", - "when": "gitlens:enabled && gitlens:views:fileHistory == gitlens" + "when": "gitlens:enabled && config.gitlens.views.fileHistory.enabled && config.gitlens.views.fileHistory.location == gitlens" }, { "id": "gitlens.views.lineHistory:gitlens", "name": "Line History", - "when": "gitlens:enabled && gitlens:views:lineHistory == gitlens" + "when": "gitlens:enabled && config.gitlens.views.lineHistory.enabled && config.gitlens.views.lineHistory.location == gitlens" }, { "id": "gitlens.views.results:gitlens", "name": "Results", - "when": "gitlens:enabled && gitlens:views:results == gitlens" + "when": "gitlens:enabled && gitlens:views:results && config.gitlens.views.results.location == gitlens" } ], "explorer": [ { "id": "gitlens.views.repositories:explorer", "name": "GitLens: Repositories", - "when": "gitlens:enabled && gitlens:views:repositories == explorer" + "when": "gitlens:enabled && config.gitlens.views.repositories.enabled && config.gitlens.views.repositories.location == explorer" }, { "id": "gitlens.views.fileHistory:explorer", "name": "GitLens: File History", - "when": "gitlens:enabled && gitlens:views:fileHistory == explorer" + "when": "gitlens:enabled && config.gitlens.views.fileHistory.enabled && config.gitlens.views.fileHistory.location == explorer" }, { "id": "gitlens.views.lineHistory:explorer", "name": "GitLens: Line History", - "when": "gitlens:enabled && gitlens:views:lineHistory == explorer" + "when": "gitlens:enabled && config.gitlens.views.lineHistory.enabled && config.gitlens.views.lineHistory.location == explorer" }, { "id": "gitlens.views.results:explorer", "name": "GitLens: Results", - "when": "gitlens:enabled && gitlens:views:results == explorer" + "when": "gitlens:enabled && gitlens:views:results && config.gitlens.views.results.location == explorer" } ], "scm": [ { "id": "gitlens.views.repositories:scm", "name": "GitLens: Repositories", - "when": "gitlens:enabled && gitlens:views:repositories == scm" + "when": "gitlens:enabled && config.gitlens.views.repositories.enabled && config.gitlens.views.repositories.location == scm" }, { "id": "gitlens.views.fileHistory:scm", "name": "GitLens: File History", - "when": "gitlens:enabled && gitlens:views:fileHistory == scm" + "when": "gitlens:enabled && config.gitlens.views.fileHistory.enabled && config.gitlens.views.fileHistory.location == scm" }, { "id": "gitlens.views.lineHistory:scm", "name": "GitLens: Line History", - "when": "gitlens:enabled && gitlens:views:lineHistory == scm" + "when": "gitlens:enabled && config.gitlens.views.lineHistory.enabled && config.gitlens.views.lineHistory.location == scm" }, { "id": "gitlens.views.results:scm", "name": "GitLens: Results", - "when": "gitlens:enabled && gitlens:views:results == scm" + "when": "gitlens:enabled && gitlens:views:results && config.gitlens.views.results.location == scm" } ] } diff --git a/src/commands.ts b/src/commands.ts index d232d9e..ba8b5ca 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -97,8 +97,6 @@ export * from './commands/toggleFileRecentChanges'; export * from './commands/toggleLineBlame'; export function configureCommands(): void { - setCommandContext(CommandContext.KeyMap, Container.config.keymap); - Container.context.subscriptions.push(new ClearFileAnnotationsCommand()); Container.context.subscriptions.push(new CloseUnchangedFilesCommand()); Container.context.subscriptions.push(new CopyMessageToClipboardCommand()); diff --git a/src/configuration.ts b/src/configuration.ts index 8ac6ca2..cfeed32 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -60,11 +60,6 @@ export class Configuration { clearGravatarCache(); } - const section = configuration.name('keymap').value; - if (configuration.changed(e, section)) { - setCommandContext(CommandContext.KeyMap, this.get(section)); - } - if ( configuration.changed(e, configuration.name('mode').value) || configuration.changed(e, configuration.name('modes').value) diff --git a/src/constants.ts b/src/constants.ts index cb838f1..040e49e 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -33,13 +33,9 @@ export enum CommandContext { Enabled = 'gitlens:enabled', HasRemotes = 'gitlens:hasRemotes', Key = 'gitlens:key', - KeyMap = 'gitlens:keymap', ViewsCanCompare = 'gitlens:views:canCompare', - ViewsFileHistory = 'gitlens:views:fileHistory', ViewsFileHistoryEditorFollowing = 'gitlens:views:fileHistory:editorFollowing', - ViewsLineHistory = 'gitlens:views:lineHistory', ViewsLineHistoryEditorFollowing = 'gitlens:views:lineHistory:editorFollowing', - ViewsRepositories = 'gitlens:views:repositories', ViewsRepositoriesAutoRefresh = 'gitlens:views:repositories:autoRefresh', ViewsResults = 'gitlens:views:results', ViewsResultsKeepResults = 'gitlens:views:results:keepResults' diff --git a/src/extension.ts b/src/extension.ts index 10a8c8c..8586e85 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -14,6 +14,9 @@ import { ModeConfig } from './ui/config'; export async function activate(context: ExtensionContext) { const start = process.hrtime(); + // Pretend we are enabled (until we know otherwise) and set the view contexts to reduce flashing on load + setCommandContext(CommandContext.Enabled, true); + Logger.configure(context); const gitlens = extensions.getExtension(extensionQualifiedId)!; @@ -33,23 +36,6 @@ export async function activate(context: ExtensionContext) { const cfg = configuration.get(); - // Pretend we are enabled (until we know otherwise) and set the view contexts to reduce flashing on load - await Promise.all([ - setCommandContext(CommandContext.Enabled, true), - setCommandContext( - CommandContext.ViewsRepositories, - cfg.views.repositories.enabled ? cfg.views.repositories.location : false - ), - setCommandContext( - CommandContext.ViewsFileHistory, - cfg.views.fileHistory.enabled ? cfg.views.fileHistory.location : false - ), - setCommandContext( - CommandContext.ViewsLineHistory, - cfg.views.lineHistory.enabled ? cfg.views.lineHistory.location : false - ) - ]); - const previousVersion = context.globalState.get(GlobalState.GitLensVersion); await migrateSettings(context, previousVersion); diff --git a/src/views/fileHistoryView.ts b/src/views/fileHistoryView.ts index 930141b..06c3d89 100644 --- a/src/views/fileHistoryView.ts +++ b/src/views/fileHistoryView.ts @@ -57,11 +57,7 @@ export class FileHistoryView extends ViewBase { return; } - if ( - configuration.changed(e, configuration.name('views')('fileHistory')('enabled').value) || - configuration.changed(e, configuration.name('views')('fileHistory')('location').value) - ) { - setCommandContext(CommandContext.ViewsFileHistory, this.config.enabled ? this.config.location : false); + if (configuration.changed(e, configuration.name('views')('fileHistory')('enabled').value)) { setCommandContext(CommandContext.ViewsFileHistoryEditorFollowing, true); } diff --git a/src/views/lineHistoryView.ts b/src/views/lineHistoryView.ts index 238e5ee..9ee42d3 100644 --- a/src/views/lineHistoryView.ts +++ b/src/views/lineHistoryView.ts @@ -56,11 +56,7 @@ export class LineHistoryView extends ViewBase { return; } - if ( - configuration.changed(e, configuration.name('views')('lineHistory')('enabled').value) || - configuration.changed(e, configuration.name('views')('lineHistory')('location').value) - ) { - setCommandContext(CommandContext.ViewsLineHistory, this.config.enabled ? this.config.location : false); + if (configuration.changed(e, configuration.name('views')('lineHistory')('enabled').value)) { setCommandContext(CommandContext.ViewsLineHistoryEditorFollowing, true); } diff --git a/src/views/repositoriesView.ts b/src/views/repositoriesView.ts index 0457952..aedbc3f 100644 --- a/src/views/repositoriesView.ts +++ b/src/views/repositoriesView.ts @@ -68,13 +68,6 @@ export class RepositoriesView extends ViewBase { return; } - if ( - configuration.changed(e, configuration.name('views')('repositories')('enabled').value) || - configuration.changed(e, configuration.name('views')('repositories')('location').value) - ) { - setCommandContext(CommandContext.ViewsRepositories, this.config.enabled ? this.config.location : false); - } - if (configuration.changed(e, configuration.name('views')('repositories')('autoRefresh').value)) { void this.setAutoRefresh(Container.config.views.repositories.autoRefresh); } diff --git a/src/views/resultsView.ts b/src/views/resultsView.ts index b4db6eb..a43681e 100644 --- a/src/views/resultsView.ts +++ b/src/views/resultsView.ts @@ -77,10 +77,6 @@ export class ResultsView extends ViewBase { } if (configuration.changed(e, configuration.name('views')('results')('location').value)) { - setCommandContext(CommandContext.ViewsResults, this.enabled ? this.config.location : false); - } - - if (configuration.changed(e, configuration.name('views')('results')('location').value)) { this.initialize(this.config.location); } @@ -194,7 +190,7 @@ export class ResultsView extends ViewBase { this._root.addOrReplace(results, !this.keepResults); this._enabled = true; - await setCommandContext(CommandContext.ViewsResults, this.config.location); + await setCommandContext(CommandContext.ViewsResults, true); setTimeout(() => this._tree!.reveal(results, { select: true }), 250); }