diff --git a/package.json b/package.json index 3a0e2ee..480fcfe 100644 --- a/package.json +++ b/package.json @@ -2120,18 +2120,6 @@ "markdownDescription": "Specifies when to switch between displaying files as a `tree` or `list` based on the number of files in a nesting level in the _Tags_ view. Only applies when `#gitlens.views.tags.files.layout#` is set to `auto`", "scope": "window" }, - "gitlens.views.updates.enabled": { - "type": "boolean", - "default": true, - "markdownDescription": "Specifies whether to show the _Updates_ view", - "scope": "window" - }, - "gitlens.views.welcome.enabled": { - "type": "boolean", - "default": true, - "markdownDescription": "Specifies whether to show the _Welcome_ view", - "scope": "window" - }, "gitlens.advanced.abbreviatedShaLength": { "type": "number", "default": "7", @@ -7714,58 +7702,54 @@ "viewsWelcome": [ { "view": "gitlens.views.welcome", - "contents": "GitLens 11 is powerful, feature rich, and highly customizable to meet your needs. You can use the GitLens Welcome experience to get setup quickly.\n\n[Welcome (Quick Setup)](command:gitlens.showWelcomePage \"Opens the GitLens Welcome (Quick Setup)\")\n\nFor more options, use the [GitLens: Open Settings](command:gitlens.showSettingsPage \"Opens the GitLens Interactive Settings\") command from the Command Palette, to open the interactive GitLens settings editor." + "contents": "GitLens 11 is powerful, feature rich, and highly customizable to meet your needs. You can use the GitLens Welcome experience to get setup quickly.\n\n[Welcome (Quick Setup)](command:gitlens.showWelcomePage \"Opens the GitLens Welcome (Quick Setup)\")\n\nFor more options, run [GitLens: Open Settings](command:gitlens.showSettingsPage \"Opens the GitLens Interactive Settings\") from the Command Palette to open the interactive GitLens settings editor." }, { "view": "gitlens.views.welcome", - "contents": "You can also quickly switch between different side bar layouts for GitLens views to best match your workflow, via the [GitLens: Set Views Layout](command:gitlens.setViewsLayout \"Changes the GitLens Views Layout\") command from the Command Palette." + "contents": "[GitLens views](command:gitlens.showSettingsPage%23views) are shown on the Source Control side bar, by default. Run [GitLens: Set Views Layout](command:gitlens.setViewsLayout \"Changes the GitLens Views Layout\") from the Command Palette to switch to an alternate side bar layout, or drag & drop them." }, { "view": "gitlens.views.welcome", - "contents": "And if you find GitLens useful, please consider sponsoring it.\n\n[Sponsor GitLens ❤](command:gitlens.supportGitLens)" + "contents": "[Sponsor GitLens ❤](command:gitlens.supportGitLens)\n\nIf you find GitLens useful, please consider sponsoring it." }, { "view": "gitlens.views.welcome", - "contents": "Once you are satisfied, feel free to [close this view](command:gitlens.closeWelcomeView \"Closes the Welcome view\")." - }, - { - "view": "gitlens.views.updates", - "contents": "[What's New in GitLens 11](https://gitlens.amod.io/#whats-new \"Opens the What's New page on the GitLens website\")\n\n[Sponsor GitLens ❤](command:gitlens.supportGitLens)\n\nSee the [release notes](https://github.com/eamodio/vscode-gitlens/blob/master/CHANGELOG.md \"Opens the Release Notes\") for the full set of changes." + "contents": "[Close](command:gitlens.closeWelcomeView \"Closes the Welcome view\")" }, { "view": "gitlens.views.updates", - "contents": "VIEW CHANGES (🧀 has been moved)" + "contents": "[GitLens views](command:gitlens.showSettingsPage%23views) have moved to the Source Control side bar.\nRun [GitLens: Set Views Layout](command:gitlens.setViewsLayout \"Changes the GitLens Views Layout\") from the Command Palette to switch to an alternate side bar layout, or drag & drop them." }, { "view": "gitlens.views.updates", - "contents": "All [GitLens views](command:gitlens.showSettingsPage%23views) have been moved to the Source Control side bar, by default. You can easily switch between different side bar layouts for GitLens views to best match your workflow, via the [GitLens: Set Views Layout](command:gitlens.setViewsLayout \"Changes the GitLens Views Layout\") command from the Command Palette." + "contents": "★ [Repositories](command:gitlens.showSettingsPage%23repositories-view) — replaced by [Commits](command:gitlens.showSettingsPage%23commits-view), [Branches](command:gitlens.showSettingsPage%23branches-view), [Remotes](command:gitlens.showSettingsPage%23remotes-view), [Stashes](command:gitlens.showSettingsPage%23stashes-view), [Tags](command:gitlens.showSettingsPage%23tags-view), and [Contributors](command:gitlens.showSettingsPage%23contributors-view) views. If you want it back, [click here](command:gitlens.showRepositoriesView)." }, { "view": "gitlens.views.updates", - "contents": "The [Repositories](command:gitlens.showSettingsPage%23repositories-view) view has been superseded by many new views: [Commits](command:gitlens.showSettingsPage%23commits-view), [Branches](command:gitlens.showSettingsPage%23branches-view), [Remotes](command:gitlens.showSettingsPage%23remotes-view), [Stashes](command:gitlens.showSettingsPage%23stashes-view), [Tags](command:gitlens.showSettingsPage%23tags-view), and [Contributors](command:gitlens.showSettingsPage%23contributors-view). Although, if you want to continue using the Repositories view, you can [click here](command:gitlens.showRepositoriesView) to re-enable it." + "contents": "★ [File History](command:gitlens.showSettingsPage%23file-history-view) — combines file and line history into a single view" }, { "view": "gitlens.views.updates", - "contents": "The Line History view has been integrated directly into the [File History](command:gitlens.showSettingsPage%23file-history-view) view." + "contents": "★ [Search & Compare](command:gitlens.showSettingsPage%23search-compare-view) — combines Search Commits and Compare Commits into a single view" }, { "view": "gitlens.views.updates", - "contents": "The Search Commits and Compare Commits views have been combined into a more powerful and user-friendly [Search & Compare](command:gitlens.showSettingsPage%23search-compare-view) view." + "contents": "[Close](command:gitlens.closeUpdatesView)" } ], "views": { "gitlens": [ { "id": "gitlens.views.updates", - "name": "What's New in GitLens 11", - "when": "config.gitlens.views.updates.enabled", + "name": "Where did my views go?", + "when": "gitlens:views:updates:visible != false", "contextualTitle": "GitLens", "icon": "images/gitlens-activitybar.svg" }, { "id": "gitlens.views.welcome", "name": "Welcome", - "when": "config.gitlens.views.welcome.enabled", + "when": "gitlens:views:welcome:visible != false", "contextualTitle": "GitLens", "icon": "images/gitlens-activitybar.svg" } diff --git a/src/annotations/annotationProvider.ts b/src/annotations/annotationProvider.ts index 5db824b..11f5fd4 100644 --- a/src/annotations/annotationProvider.ts +++ b/src/annotations/annotationProvider.ts @@ -11,7 +11,7 @@ import { window, } from 'vscode'; import { FileAnnotationType } from '../configuration'; -import { CommandContext, setCommandContext } from '../constants'; +import { ContextKeys, setContext } from '../constants'; import { Logger } from '../logger'; import { GitDocumentState, TrackedDocument } from '../trackers/gitDocumentTracker'; @@ -90,7 +90,7 @@ export abstract class AnnotationProviderBase implements Disposable { this.status = AnnotationStatus.Computing; if (editor === window.activeTextEditor) { - await setCommandContext(CommandContext.AnnotationStatus, this.status); + await setContext(ContextKeys.AnnotationStatus, this.status); } this.editor = editor; @@ -105,7 +105,7 @@ export abstract class AnnotationProviderBase implements Disposable { this.status = AnnotationStatus.Computed; if (editor === window.activeTextEditor) { - await setCommandContext(CommandContext.AnnotationStatus, this.status); + await setContext(ContextKeys.AnnotationStatus, this.status); } } diff --git a/src/annotations/fileAnnotationController.ts b/src/annotations/fileAnnotationController.ts index 24c676a..c9e1c4c 100644 --- a/src/annotations/fileAnnotationController.ts +++ b/src/annotations/fileAnnotationController.ts @@ -26,7 +26,7 @@ import { configuration, FileAnnotationType, } from '../configuration'; -import { CommandContext, isTextEditor, setCommandContext } from '../constants'; +import { ContextKeys, isTextEditor, setContext } from '../constants'; import { Container } from '../container'; import { GutterBlameAnnotationProvider } from './gutterBlameAnnotationProvider'; import { GutterChangesAnnotationProvider } from './gutterChangesAnnotationProvider'; @@ -238,10 +238,10 @@ export class FileAnnotationController implements Disposable { const provider = this.getProvider(editor); if (provider == null) { - void setCommandContext(CommandContext.AnnotationStatus, undefined); + void setContext(ContextKeys.AnnotationStatus, undefined); void this.detachKeyboardHook(); } else { - void setCommandContext(CommandContext.AnnotationStatus, provider.status); + void setContext(ContextKeys.AnnotationStatus, provider.status); void this.attachKeyboardHook(); } } @@ -385,7 +385,7 @@ export class FileAnnotationController implements Disposable { const provider = await window.withProgress( { location: ProgressLocation.Window }, async (progress: Progress<{ message: string }>) => { - await setCommandContext(CommandContext.AnnotationStatus, AnnotationStatus.Computing); + await setContext(ContextKeys.AnnotationStatus, AnnotationStatus.Computing); const computingAnnotations = this.showAnnotationsCore( currentProvider, @@ -397,7 +397,7 @@ export class FileAnnotationController implements Disposable { const provider = await computingAnnotations; if (editor === this._editor) { - await setCommandContext(CommandContext.AnnotationStatus, provider?.status); + await setContext(ContextKeys.AnnotationStatus, provider?.status); } return computingAnnotations; @@ -465,7 +465,7 @@ export class FileAnnotationController implements Disposable { provider.dispose(); if (this._annotationProviders.size === 0 || key === AnnotationProviderBase.getCorrelationKey(this._editor)) { - await setCommandContext(CommandContext.AnnotationStatus, undefined); + await setContext(ContextKeys.AnnotationStatus, undefined); await this.detachKeyboardHook(); } diff --git a/src/codelens/codeLensController.ts b/src/codelens/codeLensController.ts index 3b1aa14..d9a3425 100644 --- a/src/codelens/codeLensController.ts +++ b/src/codelens/codeLensController.ts @@ -1,7 +1,7 @@ 'use strict'; import { ConfigurationChangeEvent, Disposable, languages } from 'vscode'; import { configuration } from '../configuration'; -import { CommandContext, setCommandContext } from '../constants'; +import { ContextKeys, setContext } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; import { @@ -47,7 +47,7 @@ export class GitCodeLensController implements Disposable { } this._canToggle = cfg.recentChange.enabled || cfg.authors.enabled; - void setCommandContext(CommandContext.CanToggleCodeLens, this._canToggle); + void setContext(ContextKeys.CanToggleCodeLens, this._canToggle); } } diff --git a/src/commands/closeView.ts b/src/commands/closeView.ts index f31420a..c2795f3 100644 --- a/src/commands/closeView.ts +++ b/src/commands/closeView.ts @@ -1,6 +1,7 @@ 'use strict'; -import { configuration } from '../configuration'; import { command, Command, CommandContext, Commands } from './common'; +import { ContextKeys, GlobalState, setContext } from '../constants'; +import { Container } from '../container'; @command() export class CloseViewCommand extends Command { @@ -15,10 +16,12 @@ export class CloseViewCommand extends Command { async execute(command: Commands) { switch (command) { case Commands.CloseWelcomeView: - void (await configuration.updateEffective('views', 'welcome', 'enabled', false)); + await Container.context.globalState.update(GlobalState.WelcomeViewVisible, false); + await setContext(ContextKeys.ViewsWelcomeVisible, false); break; case Commands.CloseUpdatesView: - void (await configuration.updateEffective('views', 'updates', 'enabled', false)); + await Container.context.globalState.update(GlobalState.UpdatesViewVisible, false); + await setContext(ContextKeys.ViewsUpdatesVisible, false); break; } } diff --git a/src/commands/showView.ts b/src/commands/showView.ts index def272b..576f211 100644 --- a/src/commands/showView.ts +++ b/src/commands/showView.ts @@ -1,8 +1,9 @@ 'use strict'; import { commands } from 'vscode'; +import { command, Command, CommandContext, Commands } from './common'; import { configuration } from '../configuration'; +import { ContextKeys, GlobalState, setContext } from '../constants'; import { Container } from '../container'; -import { command, Command, CommandContext, Commands } from './common'; @command() export class ShowViewCommand extends Command { @@ -55,9 +56,8 @@ export class ShowViewCommand extends Command { case Commands.ShowTagsView: return Container.tagsView.show(); case Commands.ShowWelcomeView: - if (!Container.config.views.welcome.enabled) { - await configuration.updateEffective('views', 'welcome', 'enabled', true); - } + await setContext(ContextKeys.ViewsWelcomeVisible, true); + void Container.context.globalState.update(GlobalState.WelcomeViewVisible, true); void (await commands.executeCommand('gitlens.views.welcome.focus')); } diff --git a/src/config.ts b/src/config.ts index 4840102..04cb87e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -439,8 +439,6 @@ interface ViewsConfigs { searchAndCompare: SearchAndCompareViewConfig; stashes: StashesViewConfig; tags: TagsViewConfig; - updates: UpdatesViewConfig; - welcome: WelcomeViewConfig; } export type ViewsConfigKeys = keyof ViewsConfigs; @@ -556,14 +554,6 @@ export interface TagsViewConfig { files: ViewsFilesConfig; } -export interface UpdatesViewConfig { - enabled: boolean; -} - -export interface WelcomeViewConfig { - enabled: boolean; -} - export interface ViewsFilesConfig { compact: boolean; layout: ViewFilesLayout; diff --git a/src/constants.ts b/src/constants.ts index cc94c70..4021f65 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -31,7 +31,7 @@ export enum BuiltInCommands { ShowReferences = 'editor.action.showReferences', } -export enum CommandContext { +export enum ContextKeys { ActiveFileStatus = 'gitlens:activeFileStatus', AnnotationStatus = 'gitlens:annotationStatus', CanToggleCodeLens = 'gitlens:canToggleCodeLens', @@ -49,10 +49,12 @@ export enum CommandContext { ViewsLineHistoryEditorFollowing = 'gitlens:views:lineHistory:editorFollowing', ViewsRepositoriesAutoRefresh = 'gitlens:views:repositories:autoRefresh', ViewsSearchAndCompareKeepResults = 'gitlens:views:searchAndCompare:keepResults', + ViewsUpdatesVisible = 'gitlens:views:updates:visible', + ViewsWelcomeVisible = 'gitlens:views:welcome:visible', Vsls = 'gitlens:vsls', } -export function setCommandContext(key: CommandContext | string, value: any) { +export function setContext(key: ContextKeys | string, value: any) { return commands.executeCommand(BuiltInCommands.SetContext, key, value); } @@ -135,6 +137,8 @@ export enum GlobalState { Avatars = 'gitlens:avatars', DisallowConnectionPrefix = 'gitlens:disallow:connection:', Version = 'gitlensVersion', + UpdatesViewVisible = 'gitlens:views:updates:visible', + WelcomeViewVisible = 'gitlens:views:welcome:visible', } export const ImageMimetypes: Record = { diff --git a/src/extension.ts b/src/extension.ts index c89c6e2..0b9301e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -3,7 +3,7 @@ import { commands, ExtensionContext, extensions, window, workspace } from 'vscod import { Commands, registerCommands } from './commands'; import { ViewShowBranchComparison } from './config'; import { configuration, Configuration } from './configuration'; -import { CommandContext, extensionQualifiedId, GlobalState, GlyphChars, setCommandContext } from './constants'; +import { ContextKeys, extensionQualifiedId, GlobalState, GlyphChars, setContext } from './constants'; import { Container } from './container'; import { Git, GitCommit } from './git/git'; import { GitService } from './git/gitService'; @@ -17,7 +17,24 @@ 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 - void setCommandContext(CommandContext.Enabled, true); + void setContext(ContextKeys.Enabled, true); + + const previousVersion = context.globalState.get(GlobalState.Version); + + if (previousVersion == null) { + void context.globalState.update(GlobalState.WelcomeViewVisible, true); + void setContext(ContextKeys.ViewsWelcomeVisible, true); + void setContext(ContextKeys.ViewsUpdatesVisible, false); + } else { + void setContext( + ContextKeys.ViewsWelcomeVisible, + context.globalState.get(GlobalState.WelcomeViewVisible) ?? false, + ); + void setContext( + ContextKeys.ViewsUpdatesVisible, + context.globalState.get(GlobalState.UpdatesViewVisible) !== false, + ); + } Logger.configure(context, configuration.get('outputLevel'), o => { if (GitUri.is(o)) { @@ -43,8 +60,8 @@ export async function activate(context: ExtensionContext) { const enabled = workspace.getConfiguration('git', null).get('enabled', true); if (!enabled) { Logger.log(`GitLens (v${gitlensVersion}) was NOT activated -- "git.enabled": false`); - void setCommandContext(CommandContext.Enabled, false); - void setCommandContext(CommandContext.Disabled, true); + void setContext(ContextKeys.Enabled, false); + void setContext(ContextKeys.Disabled, true); void Messages.showGitDisabledErrorMessage(); @@ -55,14 +72,13 @@ export async function activate(context: ExtensionContext) { const cfg = configuration.get(); - const previousVersion = context.globalState.get(GlobalState.Version); await migrateSettings(context, previousVersion); try { await GitService.initialize(); } catch (ex) { Logger.error(ex, `GitLens (v${gitlensVersion}) activate`); - void setCommandContext(CommandContext.Enabled, false); + void setContext(ContextKeys.Enabled, false); const msg: string = ex?.message ?? ''; if (msg.includes('Unable to find git')) { @@ -155,7 +171,7 @@ function notifyOnUnsupportedGitVersion(version: string) { } async function showWelcomeOrWhatsNew(version: string, previousVersion: string | undefined) { - if (previousVersion === undefined) { + if (previousVersion == null) { Logger.log('GitLens first-time install'); await commands.executeCommand(Commands.ShowWelcomePage); @@ -177,18 +193,7 @@ async function showWelcomeOrWhatsNew(version: string, previousVersion: string | return; } - if (major !== prevMajor) { - if (Container.config.showWhatsNewAfterUpgrades && Container.config.views.welcome.enabled) { - await commands.executeCommand(Commands.ShowWelcomeView); - } - - // if (Container.config.showWhatsNewAfterUpgrades) { - // await Messages.showWhatsNewMessage(version); - // } - - // // Show a views upgrade notification - // if (major === 11) { - // await Messages.showViewsUpgradeMessage(); - // } + if (major !== prevMajor && Container.config.showWhatsNewAfterUpgrades) { + await Messages.showWhatsNewMessage(version); } } diff --git a/src/git/gitService.ts b/src/git/gitService.ts index 925efff..4f3b21b 100644 --- a/src/git/gitService.ts +++ b/src/git/gitService.ts @@ -21,7 +21,7 @@ import { import { API as BuiltInGitApi, Repository as BuiltInGitRepository, GitExtension } from '../@types/git'; import { resetAvatarCache } from '../avatars'; import { BranchSorting, configuration, TagSorting } from '../configuration'; -import { CommandContext, DocumentSchemes, GlyphChars, setCommandContext } from '../constants'; +import { ContextKeys, DocumentSchemes, GlyphChars, setContext } from '../constants'; import { Container } from '../container'; import { LogCorrelationContext, Logger } from '../logger'; import { Messages } from '../messages'; @@ -437,7 +437,7 @@ export class GitService implements Disposable { private async updateContext(repositoryTree: TernarySearchTree) { const hasRepository = repositoryTree.any(); - await setCommandContext(CommandContext.Enabled, hasRepository); + await setContext(ContextKeys.Enabled, hasRepository); let hasRemotes = false; let hasConnectedRemotes = false; @@ -455,8 +455,8 @@ export class GitService implements Disposable { } } - await setCommandContext(CommandContext.HasRemotes, hasRemotes); - await setCommandContext(CommandContext.HasConnectedRemotes, hasConnectedRemotes); + await setContext(ContextKeys.HasRemotes, hasRemotes); + await setContext(ContextKeys.HasConnectedRemotes, hasConnectedRemotes); // If we have no repositories setup a watcher in case one is initialized if (!hasRepository) { diff --git a/src/keyboard.ts b/src/keyboard.ts index 0152f16..757f32f 100644 --- a/src/keyboard.ts +++ b/src/keyboard.ts @@ -1,6 +1,6 @@ 'use strict'; import { commands, Disposable } from 'vscode'; -import { CommandContext, extensionId, setCommandContext } from './constants'; +import { ContextKeys, extensionId, setContext } from './constants'; import { Logger } from './logger'; import { log } from './system'; @@ -84,7 +84,7 @@ export class KeyboardScope implements Disposable { } mapping[key] = undefined; - await setCommandContext(`${CommandContext.Key}:${key}`, false); + await setContext(`${ContextKeys.Key}:${key}`, false); } @log({ @@ -138,12 +138,12 @@ export class KeyboardScope implements Disposable { mapping[key] = command; if (!set) { - await setCommandContext(`${CommandContext.Key}:${key}`, true); + await setContext(`${ContextKeys.Key}:${key}`, true); } } private async updateKeyCommandsContext(mapping: KeyMapping) { - await Promise.all(keys.map(key => setCommandContext(`${CommandContext.Key}:${key}`, Boolean(mapping?.[key])))); + await Promise.all(keys.map(key => setContext(`${ContextKeys.Key}:${key}`, Boolean(mapping?.[key])))); } } diff --git a/src/messages.ts b/src/messages.ts index 5ebf9ec..74cbe6f 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -1,6 +1,5 @@ 'use strict'; -import { commands, ConfigurationTarget, env, MessageItem, Uri, window } from 'vscode'; -import { Commands } from './commands'; +import { ConfigurationTarget, env, MessageItem, Uri, window } from 'vscode'; import { configuration } from './configuration'; import { GitCommit } from './git/git'; import { Logger } from './logger'; @@ -95,21 +94,21 @@ export class Messages { ); } - static async showViewsUpgradeMessage() { - const openSettings: MessageItem = { title: 'Open Settings' }; - - const result = await Messages.showMessage( - 'info', - 'GitLens 11 has replaced the Repositories view with many new views, and integrated the Line History view into the File History view. To re-enable either of these views, open the GitLens Interactive Settings.', - undefined, - null, - openSettings, - ); - - if (result === openSettings) { - await commands.executeCommand(Commands.ShowSettingsPageAndJumpToRepositoriesView); - } - } + // static async showViewsUpgradeMessage() { + // const openSettings: MessageItem = { title: 'Open Settings' }; + + // const result = await Messages.showMessage( + // 'info', + // 'GitLens 11 has replaced the Repositories view with many new views, and integrated the Line History view into the File History view. To re-enable either of these views, open the GitLens Interactive Settings.', + // undefined, + // null, + // openSettings, + // ); + + // if (result === openSettings) { + // await commands.executeCommand(Commands.ShowSettingsPageAndJumpToRepositoriesView); + // } + // } static async showWhatsNewMessage(version: string) { const actions: MessageItem[] = [{ title: "What's New" }, { title: 'Release Notes' }, { title: '❤' }]; diff --git a/src/trackers/documentTracker.ts b/src/trackers/documentTracker.ts index ffcb6fd..6fe769e 100644 --- a/src/trackers/documentTracker.ts +++ b/src/trackers/documentTracker.ts @@ -17,7 +17,7 @@ import { workspace, } from 'vscode'; import { configuration } from '../configuration'; -import { CommandContext, DocumentSchemes, isActiveDocument, isTextEditor, setCommandContext } from '../constants'; +import { ContextKeys, DocumentSchemes, isActiveDocument, isTextEditor, setContext } from '../constants'; import { GitUri } from '../git/gitUri'; import { Functions } from '../system'; import { DocumentBlameStateChangeEvent, TrackedDocument } from './trackedDocument'; @@ -120,7 +120,7 @@ export class DocumentTracker implements Disposable { this._timer = setTimeout(() => { this._timer = undefined; - void setCommandContext(CommandContext.ActiveFileStatus, undefined); + void setContext(ContextKeys.ActiveFileStatus, undefined); }, 250); return; diff --git a/src/trackers/trackedDocument.ts b/src/trackers/trackedDocument.ts index 899bb27..b622c30 100644 --- a/src/trackers/trackedDocument.ts +++ b/src/trackers/trackedDocument.ts @@ -1,6 +1,6 @@ 'use strict'; import { Disposable, Event, EventEmitter, TextDocument, TextEditor, Uri } from 'vscode'; -import { CommandContext, getEditorIfActive, isActiveDocument, setCommandContext } from '../constants'; +import { ContextKeys, getEditorIfActive, isActiveDocument, setContext } from '../constants'; import { Container } from '../container'; import { GitRevision, Repository, RepositoryChange, RepositoryChangeEvent } from '../git/git'; import { GitUri } from '../git/gitUri'; @@ -126,7 +126,7 @@ export class TrackedDocument implements Disposable { } activate() { - void setCommandContext(CommandContext.ActiveFileStatus, this.getStatus()); + void setContext(ContextKeys.ActiveFileStatus, this.getStatus()); } async ensureInitialized() { @@ -203,7 +203,7 @@ export class TrackedDocument implements Disposable { if (active !== undefined) { const blameable = this.isBlameable; - void setCommandContext(CommandContext.ActiveFileStatus, this.getStatus()); + void setContext(ContextKeys.ActiveFileStatus, this.getStatus()); if (!options.initializing && wasBlameable !== blameable) { const e: DocumentBlameStateChangeEvent = { editor: active, document: this, blameable: blameable }; diff --git a/src/views/commitsView.ts b/src/views/commitsView.ts index 09b9e48..125a005 100644 --- a/src/views/commitsView.ts +++ b/src/views/commitsView.ts @@ -9,7 +9,7 @@ import { window, } from 'vscode'; import { CommitsViewConfig, configuration, ViewFilesLayout, ViewShowBranchComparison } from '../configuration'; -import { CommandContext, GlyphChars, setCommandContext } from '../constants'; +import { ContextKeys, GlyphChars, setContext } from '../constants'; import { Container } from '../container'; import { GitLogCommit, @@ -397,7 +397,7 @@ export class CommitsView extends ViewBase { } private setMyCommitsOnly(enabled: boolean) { - void setCommandContext(CommandContext.ViewsCommitsMyCommitsOnly, enabled); + void setContext(ContextKeys.ViewsCommitsMyCommitsOnly, enabled); this.state.myCommitsOnly = enabled; void this.refresh(true); } diff --git a/src/views/fileHistoryView.ts b/src/views/fileHistoryView.ts index 6a735ed..83a2a5d 100644 --- a/src/views/fileHistoryView.ts +++ b/src/views/fileHistoryView.ts @@ -1,7 +1,7 @@ 'use strict'; import { commands, ConfigurationChangeEvent } from 'vscode'; import { configuration, FileHistoryViewConfig } from '../configuration'; -import { CommandContext, setCommandContext } from '../constants'; +import { ContextKeys, setContext } from '../constants'; import { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { FileHistoryTrackerNode, LineHistoryTrackerNode } from './nodes'; @@ -95,8 +95,8 @@ export class FileHistoryView extends ViewBase { ref: ref, }); this.children.splice(0, 0, this.comparePicker); - void setCommandContext(CommandContext.ViewsCanCompare, true); + void setContext(ContextKeys.ViewsCanCompare, true); await this.triggerChange(); @@ -237,7 +237,7 @@ export class SearchAndCompareViewNode extends ViewNode { } private removeComparePicker(silent: boolean = false) { - void setCommandContext(CommandContext.ViewsCanCompare, false); + void setContext(ContextKeys.ViewsCanCompare, false); if (this.comparePicker != null) { const index = this.children.indexOf(this.comparePicker); if (index !== -1) { @@ -257,7 +257,7 @@ export class SearchAndCompareView extends ViewBase(Commands.DiffWith, { repoPath: selected.repoPath, @@ -659,7 +659,7 @@ export class ViewCommands { repoPath: node.repoPath, uri: node.uri, }; - void setCommandContext(CommandContext.ViewsCanCompareFile, true); + void setContext(ContextKeys.ViewsCanCompareFile, true); } @debug() diff --git a/src/vsls/guest.ts b/src/vsls/guest.ts index f8b5494..be9297c 100644 --- a/src/vsls/guest.ts +++ b/src/vsls/guest.ts @@ -1,7 +1,7 @@ 'use strict'; import { CancellationToken, Disposable, window, WorkspaceFolder } from 'vscode'; import { LiveShare, SharedServiceProxy } from 'vsls'; -import { CommandContext, setCommandContext } from '../constants'; +import { ContextKeys, setContext } from '../constants'; import { GitCommandOptions, Repository, RepositoryChangeEvent } from '../git/git'; import { Logger } from '../logger'; import { debug, log } from '../system'; @@ -38,11 +38,11 @@ export class VslsGuestService implements Disposable { @log() private onAvailabilityChanged(available: boolean) { if (available) { - void setCommandContext(CommandContext.Enabled, true); + void setContext(ContextKeys.Enabled, true); return; } - void setCommandContext(CommandContext.Enabled, false); + void setContext(ContextKeys.Enabled, false); void window.showWarningMessage( 'GitLens features will be unavailable. Unable to connect to the host GitLens service. The host may have disabled GitLens guest access or may not have GitLens installed.', ); diff --git a/src/vsls/vsls.ts b/src/vsls/vsls.ts index c25ef14..ce07fd8 100644 --- a/src/vsls/vsls.ts +++ b/src/vsls/vsls.ts @@ -1,7 +1,7 @@ 'use strict'; import { Disposable, workspace } from 'vscode'; import { getApi, LiveShare, Role, SessionChangeEvent } from 'vsls'; -import { CommandContext, DocumentSchemes, setCommandContext } from '../constants'; +import { ContextKeys, DocumentSchemes, setContext } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; import { VslsGuestService } from './guest'; @@ -63,7 +63,7 @@ export class VslsController implements Disposable { this._api = getApi(); const api = await this._api; if (api == null) { - void setCommandContext(CommandContext.Vsls, false); + void setContext(ContextKeys.Vsls, false); // Tear it down if we can't talk to live share if (this._onReady !== undefined) { this._onReady(); @@ -73,7 +73,7 @@ export class VslsController implements Disposable { return; } - void setCommandContext(CommandContext.Vsls, true); + void setContext(ContextKeys.Vsls, true); this._disposable = Disposable.from( api.onDidChangeSession(e => this.onLiveShareSessionChanged(api, e), this), @@ -93,7 +93,7 @@ export class VslsController implements Disposable { } private setReadonly(value: boolean) { this._readonly = value; - void setCommandContext(CommandContext.Readonly, value ? true : undefined); + void setContext(ContextKeys.Readonly, value ? true : undefined); } @debug() @@ -189,20 +189,20 @@ export class VslsController implements Disposable { switch (e.session.role) { case Role.Host: this.setReadonly(false); - void setCommandContext(CommandContext.Vsls, 'host'); + void setContext(ContextKeys.Vsls, 'host'); if (Container.config.liveshare.allowGuestAccess) { this._host = await VslsHostService.share(api); } break; case Role.Guest: this.setReadonly(true); - void setCommandContext(CommandContext.Vsls, 'guest'); + void setContext(ContextKeys.Vsls, 'guest'); this._guest = await VslsGuestService.connect(api); break; default: this.setReadonly(false); - void setCommandContext(CommandContext.Vsls, true); + void setContext(ContextKeys.Vsls, true); break; }