Selaa lähdekoodia

Replaces enums with types

main
Eric Amodio 1 vuosi sitten
vanhempi
commit
470a031ddd
48 muutettua tiedostoa jossa 173 lisäystä ja 225 poistoa
  1. +2
    -3
      src/annotations/annotationProvider.ts
  2. +6
    -6
      src/annotations/fileAnnotationController.ts
  3. +2
    -2
      src/api/actionRunners.ts
  4. +1
    -2
      src/avatars.ts
  5. +1
    -2
      src/codelens/codeLensController.ts
  6. +2
    -2
      src/commands/git/search.ts
  7. +4
    -4
      src/commands/git/stash.ts
  8. +3
    -3
      src/commands/gitCommands.utils.ts
  9. +38
    -36
      src/constants.ts
  10. +5
    -25
      src/context.ts
  11. +1
    -1
      src/eventBus.ts
  12. +6
    -6
      src/extension.ts
  13. +6
    -6
      src/git/gitProviderService.ts
  14. +2
    -2
      src/plus/github/githubGitProvider.ts
  15. +6
    -6
      src/plus/subscription/subscriptionService.ts
  16. +1
    -2
      src/plus/subscription/utils.ts
  17. +4
    -4
      src/plus/webviews/focus/focusWebview.ts
  18. +2
    -2
      src/plus/webviews/focus/registration.ts
  19. +5
    -5
      src/plus/webviews/graph/graphWebview.ts
  20. +3
    -3
      src/plus/webviews/graph/registration.ts
  21. +3
    -3
      src/plus/webviews/graph/statusbar.ts
  22. +3
    -3
      src/plus/webviews/timeline/registration.ts
  23. +1
    -1
      src/plus/webviews/timeline/timelineWebview.ts
  24. +4
    -4
      src/system/keyboard.ts
  25. +1
    -1
      src/trackers/documentTracker.ts
  26. +2
    -3
      src/trackers/trackedDocument.ts
  27. +2
    -2
      src/views/commitsView.ts
  28. +5
    -5
      src/views/fileHistoryView.ts
  29. +3
    -3
      src/views/lineHistoryView.ts
  30. +2
    -2
      src/views/nodes/branchNode.ts
  31. +2
    -2
      src/views/nodes/commitNode.ts
  32. +1
    -1
      src/views/nodes/fileHistoryTrackerNode.ts
  33. +1
    -2
      src/views/nodes/lineHistoryTrackerNode.ts
  34. +2
    -2
      src/views/nodes/worktreeNode.ts
  35. +2
    -2
      src/views/repositoriesView.ts
  36. +5
    -5
      src/views/searchAndCompareView.ts
  37. +3
    -3
      src/views/viewCommands.ts
  38. +7
    -7
      src/vsls/vsls.ts
  39. +3
    -4
      src/webviews/commitDetails/commitDetailsWebview.ts
  40. +1
    -2
      src/webviews/commitDetails/registration.ts
  41. +3
    -4
      src/webviews/home/homeWebview.ts
  42. +1
    -2
      src/webviews/home/registration.ts
  43. +1
    -1
      src/webviews/rebase/rebaseEditor.ts
  44. +1
    -1
      src/webviews/settings/registration.ts
  45. +9
    -28
      src/webviews/webviewController.ts
  46. +1
    -2
      src/webviews/webviewWithConfigBase.ts
  47. +3
    -7
      src/webviews/webviewsController.ts
  48. +1
    -1
      src/webviews/welcome/registration.ts

+ 2
- 3
src/annotations/annotationProvider.ts Näytä tiedosto

@ -9,7 +9,6 @@ import type {
} from 'vscode';
import { Disposable, window } from 'vscode';
import type { FileAnnotationType } from '../config';
import { ContextKeys } from '../constants';
import { setContext } from '../context';
import { Logger } from '../system/logger';
import type { GitDocumentState, TrackedDocument } from '../trackers/gitDocumentTracker';
@ -116,7 +115,7 @@ export abstract class AnnotationProviderBase
this.status = AnnotationStatus.Computing;
if (editor === window.activeTextEditor) {
await setContext(ContextKeys.AnnotationStatus, this.status);
await setContext('gitlens:annotationStatus', this.status);
}
this.editor = editor;
@ -131,7 +130,7 @@ export abstract class AnnotationProviderBase
this.status = AnnotationStatus.Computed;
if (editor === window.activeTextEditor) {
await setContext(ContextKeys.AnnotationStatus, this.status);
await setContext('gitlens:annotationStatus', this.status);
}
}

+ 6
- 6
src/annotations/fileAnnotationController.ts Näytä tiedosto

@ -21,7 +21,7 @@ import {
workspace,
} from 'vscode';
import { AnnotationsToggleMode, BlameHighlightLocations, ChangesLocations, FileAnnotationType } from '../config';
import { Colors, ContextKeys } from '../constants';
import { Colors } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import { configuration } from '../system/configuration';
@ -175,10 +175,10 @@ export class FileAnnotationController implements Disposable {
const provider = this.getProvider(editor);
if (provider == null) {
void setContext(ContextKeys.AnnotationStatus, undefined);
void setContext('gitlens:annotationStatus', undefined);
void this.detachKeyboardHook();
} else {
void setContext(ContextKeys.AnnotationStatus, provider.status);
void setContext('gitlens:annotationStatus', provider.status);
void this.attachKeyboardHook();
}
}
@ -323,13 +323,13 @@ export class FileAnnotationController implements Disposable {
const provider = await window.withProgress(
{ location: ProgressLocation.Window },
async (progress: Progress<{ message: string }>) => {
await setContext(ContextKeys.AnnotationStatus, AnnotationStatus.Computing);
await setContext('gitlens:annotationStatus', AnnotationStatus.Computing);
const computingAnnotations = this.showAnnotationsCore(currentProvider, editor, type, context, progress);
const provider = await computingAnnotations;
if (editor === this._editor) {
await setContext(ContextKeys.AnnotationStatus, provider?.status);
await setContext('gitlens:annotationStatus', provider?.status);
}
return computingAnnotations;
@ -408,7 +408,7 @@ export class FileAnnotationController implements Disposable {
provider.dispose();
if (this._annotationProviders.size === 0 || key === getEditorCorrelationKey(this._editor)) {
await setContext(ContextKeys.AnnotationStatus, undefined);
await setContext('gitlens:annotationStatus', undefined);
await this.detachKeyboardHook();
}

+ 2
- 2
src/api/actionRunners.ts Näytä tiedosto

@ -1,7 +1,7 @@
import type { Event, QuickPickItem } from 'vscode';
import { Disposable, EventEmitter, window } from 'vscode';
import type { Config } from '../config';
import { Commands, ContextKeys } from '../constants';
import { Commands } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import { registerCommand } from '../system/command';
@ -326,7 +326,7 @@ export class ActionRunners implements Disposable {
}
private async _updateContextKeys(action: Actions) {
await setContext(`${ContextKeys.ActionPrefix}${action}`, this.count(action));
await setContext(`gitlens:action:${action}`, this.count(action));
}
private async _updateAllContextKeys() {

+ 1
- 2
src/avatars.ts Näytä tiedosto

@ -1,7 +1,6 @@
import { EventEmitter, Uri } from 'vscode';
import { md5 } from '@env/crypto';
import { GravatarDefaultStyle } from './config';
import { ContextKeys } from './constants';
import { Container } from './container';
import { getContext } from './context';
import { getGitHubNoReplyAddressParts } from './git/remotes/github';
@ -126,7 +125,7 @@ function getAvatarUriCore(
const avatar = createOrUpdateAvatar(key, email, size, hash, options?.defaultStyle);
if (avatar.uri != null) return avatar.uri;
if (!options?.cached && repoPathOrCommit != null && getContext(ContextKeys.HasConnectedRemotes)) {
if (!options?.cached && repoPathOrCommit != null && getContext('gitlens:hasConnectedRemotes')) {
let query = avatarQueue.get(key);
if (query == null && hasAvatarExpired(avatar)) {
query = getAvatarUriFromRemoteProvider(avatar, key, email, repoPathOrCommit, { size: size }).then(

+ 1
- 2
src/codelens/codeLensController.ts Näytä tiedosto

@ -1,6 +1,5 @@
import type { ConfigurationChangeEvent } from 'vscode';
import { Disposable, languages } from 'vscode';
import { ContextKeys } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import { configuration } from '../system/configuration';
@ -49,7 +48,7 @@ export class GitCodeLensController implements Disposable {
}
this._canToggle = cfg.recentChange.enabled || cfg.authors.enabled;
void setContext(ContextKeys.DisabledToggleCodeLens, !this._canToggle);
void setContext('gitlens:disabledToggleCodeLens', !this._canToggle);
}
}

+ 2
- 2
src/commands/git/search.ts Näytä tiedosto

@ -1,4 +1,4 @@
import { ContextKeys, GlyphChars } from '../../constants';
import { GlyphChars } from '../../constants';
import type { Container } from '../../container';
import { getContext } from '../../context';
import { showDetailsView } from '../../git/actions/commit';
@ -114,7 +114,7 @@ export class SearchGitCommand extends QuickCommand {
repos: this.container.git.openRepositories,
associatedView: this.container.searchAndCompareView,
commit: undefined,
hasVirtualFolders: getContext<boolean>(ContextKeys.HasVirtualFolders, false),
hasVirtualFolders: getContext<boolean>('gitlens:hasVirtualFolders', false),
resultsKey: undefined,
resultsPromise: undefined,
title: this.title,

+ 4
- 4
src/commands/git/stash.ts Näytä tiedosto

@ -1,6 +1,6 @@
import type { QuickPickItem, Uri } from 'vscode';
import { QuickInputButtons, window } from 'vscode';
import { ContextKeys, GlyphChars } from '../../constants';
import { GlyphChars } from '../../constants';
import type { Container } from '../../container';
import { getContext } from '../../context';
import { reveal, showDetailsView } from '../../git/actions/stash';
@ -168,9 +168,9 @@ export class StashGitCommand extends QuickCommand {
repos: this.container.git.openRepositories,
associatedView: this.container.stashesView,
readonly:
getContext<boolean>(ContextKeys.Readonly, false) ||
getContext<boolean>(ContextKeys.Untrusted, false) ||
getContext<boolean>(ContextKeys.HasVirtualFolders, false),
getContext<boolean>('gitlens:readonly', false) ||
getContext<boolean>('gitlens:untrusted', false) ||
getContext<boolean>('gitlens:hasVirtualFolders', false),
title: this.title,
};

+ 3
- 3
src/commands/gitCommands.utils.ts Näytä tiedosto

@ -55,11 +55,11 @@ export class PickCommandStep implements QuickPickStep {
readonly title = 'GitLens';
constructor(private readonly container: Container, args?: GitCommandsCommandArgs) {
const hasVirtualFolders = getContext<boolean>(ContextKeys.HasVirtualFolders, false);
const hasVirtualFolders = getContext<boolean>('gitlens:hasVirtualFolders', false);
const readonly =
hasVirtualFolders ||
getContext<boolean>(ContextKeys.Readonly, false) ||
getContext<boolean>(ContextKeys.Untrusted, false);
getContext<boolean>('gitlens:readonly', false) ||
getContext<boolean>('gitlens:untrusted', false);
this.items = [
readonly ? undefined : new BranchGitCommand(container, args?.command === 'branch' ? args : undefined),

+ 38
- 36
src/constants.ts Näytä tiedosto

@ -1,5 +1,6 @@
export const commandPrefix = 'gitlens';
export const configPrefix = 'gitlens';
export const keyPrefix = 'gitlens:key';
export const storagePrefix = 'gitlens';
export const quickPickTitleMaxChars = 80;
@ -281,43 +282,44 @@ export const enum Commands {
Deprecated_ShowFileHistoryInView = 'gitlens.showFileHistoryInView',
}
export const enum ContextKeys {
ActionPrefix = 'gitlens:action:',
KeyPrefix = 'gitlens:key:',
WebviewPrefix = `gitlens:webview:`,
WebviewViewPrefix = `gitlens:webviewView:`,
export type CustomEditorIds = 'rebaseEditor';
export type WebviewIds = 'graph' | 'settings' | 'timeline' | 'welcome' | 'focus';
export type WebviewViewIds = 'commitDetails' | 'graph' | 'home' | 'timeline';
ActiveFileStatus = 'gitlens:activeFileStatus',
AnnotationStatus = 'gitlens:annotationStatus',
Debugging = 'gitlens:debugging',
DisabledToggleCodeLens = 'gitlens:disabledToggleCodeLens',
Disabled = 'gitlens:disabled',
Enabled = 'gitlens:enabled',
FocusFocused = 'gitlens:focus:focused',
HasConnectedRemotes = 'gitlens:hasConnectedRemotes',
HasRemotes = 'gitlens:hasRemotes',
HasRichRemotes = 'gitlens:hasRichRemotes',
HasVirtualFolders = 'gitlens:hasVirtualFolders',
PreRelease = 'gitlens:prerelease',
Readonly = 'gitlens:readonly',
Untrusted = 'gitlens:untrusted',
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',
ViewsRepositoriesAutoRefresh = 'gitlens:views:repositories:autoRefresh',
ViewsSearchAndCompareKeepResults = 'gitlens:views:searchAndCompare:keepResults',
Vsls = 'gitlens:vsls',
Plus = 'gitlens:plus',
PlusDisallowedRepos = 'gitlens:plus:disallowedRepos',
PlusEnabled = 'gitlens:plus:enabled',
PlusRequired = 'gitlens:plus:required',
PlusState = 'gitlens:plus:state',
}
export type ContextKeys =
| `gitlens:action:${string}`
| `${typeof keyPrefix}:${string}`
| `gitlens:webview:${WebviewIds | CustomEditorIds}:${'active' | 'focus' | 'inputFocus'}`
| `gitlens:webviewView:${WebviewViewIds}:${'active' | 'focus' | 'inputFocus'}`
| 'gitlens:activeFileStatus'
| 'gitlens:annotationStatus'
| 'gitlens:debugging'
| 'gitlens:disabledToggleCodeLens'
| 'gitlens:disabled'
| 'gitlens:enabled'
| 'gitlens:focus:focused' // TODO@eamodio do we need this?
| 'gitlens:hasConnectedRemotes'
| 'gitlens:hasRemotes'
| 'gitlens:hasRichRemotes'
| 'gitlens:hasVirtualFolders'
| 'gitlens:prerelease'
| 'gitlens:readonly'
| 'gitlens:untrusted'
| 'gitlens:views:canCompare'
| 'gitlens:views:canCompare:file'
| 'gitlens:views:commits:myCommitsOnly'
| 'gitlens:views:fileHistory:canPin'
| 'gitlens:views:fileHistory:cursorFollowing'
| 'gitlens:views:fileHistory:editorFollowing'
| 'gitlens:views:lineHistory:editorFollowing'
| 'gitlens:views:repositories:autoRefresh'
| 'gitlens:views:searchAndCompare:keepResults'
| 'gitlens:vsls'
| 'gitlens:plus'
| 'gitlens:plus:disallowedRepos'
| 'gitlens:plus:enabled'
| 'gitlens:plus:required'
| 'gitlens:plus:state';
export type CoreCommands =
| 'cursorMove'

+ 5
- 25
src/context.ts Näytä tiedosto

@ -1,39 +1,19 @@
import { EventEmitter } from 'vscode';
import type { ContextKeys } from './constants';
import { executeCoreCommand } from './system/command';
import type { WebviewIds, WebviewViewIds } from './webviews/webviewsController';
const contextStorage = new Map<string, unknown>();
type WebviewContextKeys =
| `${ContextKeys.WebviewPrefix}${WebviewIds}:active`
| `${ContextKeys.WebviewPrefix}${WebviewIds}:focus`
| `${ContextKeys.WebviewPrefix}${WebviewIds}:inputFocus`
| `${ContextKeys.WebviewPrefix}rebaseEditor:active`
| `${ContextKeys.WebviewPrefix}rebaseEditor:focus`
| `${ContextKeys.WebviewPrefix}rebaseEditor:inputFocus`;
type WebviewViewContextKeys =
| `${ContextKeys.WebviewViewPrefix}${WebviewViewIds}:focus`
| `${ContextKeys.WebviewViewPrefix}${WebviewViewIds}:inputFocus`;
type AllContextKeys =
| ContextKeys
| WebviewContextKeys
| WebviewViewContextKeys
| `${ContextKeys.ActionPrefix}${string}`
| `${ContextKeys.KeyPrefix}${string}`;
const _onDidChangeContext = new EventEmitter<AllContextKeys>();
const _onDidChangeContext = new EventEmitter<ContextKeys>();
export const onDidChangeContext = _onDidChangeContext.event;
export function getContext<T>(key: AllContextKeys): T | undefined;
export function getContext<T>(key: AllContextKeys, defaultValue: T): T;
export function getContext<T>(key: AllContextKeys, defaultValue?: T): T | undefined {
export function getContext<T>(key: ContextKeys): T | undefined;
export function getContext<T>(key: ContextKeys, defaultValue: T): T;
export function getContext<T>(key: ContextKeys, defaultValue?: T): T | undefined {
return (contextStorage.get(key) as T | undefined) ?? defaultValue;
}
export async function setContext(key: AllContextKeys, value: unknown): Promise<void> {
export async function setContext(key: ContextKeys, value: unknown): Promise<void> {
contextStorage.set(key, value);
void (await executeCoreCommand('setContext', key, value));
_onDidChangeContext.fire(key);

+ 1
- 1
src/eventBus.ts Näytä tiedosto

@ -1,10 +1,10 @@
import type { Disposable, Uri } from 'vscode';
import { EventEmitter } from 'vscode';
import type { ViewsConfigKeys } from './config';
import type { WebviewIds, WebviewViewIds } from './constants';
import type { GitCaches } from './git/gitProvider';
import type { GitCommit } from './git/models/commit';
import type { GitRevisionReference } from './git/models/reference';
import type { WebviewIds, WebviewViewIds } from './webviews/webviewsController';
export type CommitSelectedEvent = EventBusEvent<'commit:selected'>;
interface CommitSelectedEventArgs {

+ 6
- 6
src/extension.ts Näytä tiedosto

@ -6,7 +6,7 @@ import { Api } from './api/api';
import type { CreatePullRequestActionContext, GitLensApi, OpenPullRequestActionContext } from './api/gitlens';
import type { CreatePullRequestOnRemoteCommandArgs, OpenPullRequestOnRemoteCommandArgs } from './commands';
import { fromOutputLevel, OutputLevel } from './config';
import { Commands, ContextKeys } from './constants';
import { Commands } from './constants';
import { Container } from './container';
import { setContext } from './context';
import { isGitUri } from './git/gitUri';
@ -85,7 +85,7 @@ export async function activate(context: ExtensionContext): Promise
}
if (!workspace.isTrusted) {
void setContext(ContextKeys.Untrusted, true);
void setContext('gitlens:untrusted', true);
}
setKeysForSync(context);
@ -136,7 +136,7 @@ export async function activate(context: ExtensionContext): Promise
if (!workspace.isTrusted) {
context.subscriptions.push(
workspace.onDidGrantWorkspaceTrust(() => {
void setContext(ContextKeys.Untrusted, undefined);
void setContext('gitlens:untrusted', undefined);
container.telemetry.setGlobalAttribute('workspace.isTrusted', workspace.isTrusted);
}),
);
@ -166,11 +166,11 @@ export async function activate(context: ExtensionContext): Promise
if (container.debugging) {
// Set context to only show some commands when using the pre-release version or debugging
void setContext(ContextKeys.Debugging, true);
void setContext(ContextKeys.PreRelease, true);
void setContext('gitlens:debugging', true);
void setContext('gitlens:prerelease', true);
} else if (container.prerelease) {
// Set context to only show some commands when using the pre-release version
void setContext(ContextKeys.PreRelease, true);
void setContext('gitlens:prerelease', true);
}
// Signal that the container is now ready

+ 6
- 6
src/git/gitProviderService.ts Näytä tiedosto

@ -12,7 +12,7 @@ import type {
import { Disposable, EventEmitter, FileType, ProgressLocation, Uri, window, workspace } from 'vscode';
import { resetAvatarCache } from '../avatars';
import type { CoreGitConfiguration } from '../constants';
import { ContextKeys, GlyphChars, Schemes } from '../constants';
import { GlyphChars, Schemes } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import { AccessDeniedError, ProviderNotFoundError } from '../errors';
@ -948,12 +948,12 @@ export class GitProviderService implements Disposable {
if (this._context.enabled !== enabled) {
this._context.enabled = enabled;
promises.push(setContext(ContextKeys.Enabled, enabled));
promises.push(setContext('gitlens:enabled', enabled));
}
if (this._context.disabled !== disabled) {
this._context.disabled = disabled;
promises.push(setContext(ContextKeys.Disabled, disabled));
promises.push(setContext('gitlens:disabled', disabled));
}
await Promise.allSettled(promises);
@ -1045,9 +1045,9 @@ export class GitProviderService implements Disposable {
}
await Promise.allSettled([
setContext(ContextKeys.HasRemotes, hasRemotes),
setContext(ContextKeys.HasRichRemotes, hasRichRemotes),
setContext(ContextKeys.HasConnectedRemotes, hasConnectedRemotes),
setContext('gitlens:hasRemotes', hasRemotes),
setContext('gitlens:hasRichRemotes', hasRichRemotes),
setContext('gitlens:hasConnectedRemotes', hasConnectedRemotes),
]);
}

+ 2
- 2
src/plus/github/githubGitProvider.ts Näytä tiedosto

@ -11,7 +11,7 @@ import type {
} from 'vscode';
import { authentication, EventEmitter, FileType, Uri, window, workspace } from 'vscode';
import { encodeUtf8Hex } from '@env/hex';
import { CharCode, ContextKeys, Schemes } from '../../constants';
import { CharCode, Schemes } from '../../constants';
import type { Container } from '../../container';
import { setContext } from '../../context';
import { emojify } from '../../emojis';
@ -194,7 +194,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
}
updateContext(): void {
void setContext(ContextKeys.HasVirtualFolders, this.container.git.hasOpenRepositories(this.descriptor.id));
void setContext('gitlens:hasVirtualFolders', this.container.git.hasOpenRepositories(this.descriptor.id));
}
openRepository(

+ 6
- 6
src/plus/subscription/subscriptionService.ts Näytä tiedosto

@ -22,7 +22,7 @@ import {
} from 'vscode';
import { fetch, getProxyAgent } from '@env/fetch';
import { getPlatform } from '@env/platform';
import { Commands, ContextKeys } from '../../constants';
import { Commands } from '../../constants';
import type { Container } from '../../container';
import { setContext } from '../../context';
import { AccountValidationError } from '../../errors';
@ -973,8 +973,8 @@ export class SubscriptionService implements Disposable {
state,
} = this._subscription;
void setContext(ContextKeys.Plus, actual.id != SubscriptionPlanId.Free ? actual.id : undefined);
void setContext(ContextKeys.PlusState, state);
void setContext('gitlens:plus', actual.id != SubscriptionPlanId.Free ? actual.id : undefined);
void setContext('gitlens:plus:state', state);
}
private async updateAccessContext(cancellation: CancellationToken): Promise<void> {
@ -1003,9 +1003,9 @@ export class SubscriptionService implements Disposable {
}
}
void setContext(ContextKeys.PlusEnabled, Boolean(allowed) || plusFeatures);
void setContext(ContextKeys.PlusRequired, allowed === false);
void setContext(ContextKeys.PlusDisallowedRepos, disallowedRepos);
void setContext('gitlens:plus:enabled', Boolean(allowed) || plusFeatures);
void setContext('gitlens:plus:required', allowed === false);
void setContext('gitlens:plus:disallowedRepos', disallowedRepos);
}
private updateStatusBar(): void {

+ 1
- 2
src/plus/subscription/utils.ts Näytä tiedosto

@ -1,11 +1,10 @@
import type { MessageItem } from 'vscode';
import { window } from 'vscode';
import { ContextKeys } from '../../constants';
import { getContext } from '../../context';
import { configuration } from '../../system/configuration';
export function arePlusFeaturesEnabled(): boolean {
return getContext(ContextKeys.PlusEnabled, configuration.get('plusFeatures.enabled', undefined, true));
return getContext('gitlens:plus:enabled', configuration.get('plusFeatures.enabled', undefined, true));
}
export async function ensurePlusFeaturesEnabled(): Promise<boolean> {

+ 4
- 4
src/plus/webviews/focus/focusWebview.ts Näytä tiedosto

@ -1,6 +1,7 @@
import { Disposable, Uri, window } from 'vscode';
import type { GHPRPullRequest } from '../../../commands';
import { Commands, ContextKeys } from '../../../constants';
import type { WebviewIds, WebviewViewIds } from '../../../constants';
import { Commands } from '../../../constants';
import type { Container } from '../../../container';
import { setContext } from '../../../context';
import { PlusFeatures } from '../../../features';
@ -26,7 +27,6 @@ import { executeCommand, registerCommand } from '../../../system/command';
import type { IpcMessage } from '../../../webviews/protocol';
import { onIpc } from '../../../webviews/protocol';
import type { WebviewController, WebviewProvider } from '../../../webviews/webviewController';
import type { WebviewIds, WebviewViewIds } from '../../../webviews/webviewsController';
import type { SubscriptionChangeEvent } from '../../subscription/subscriptionService';
import type { OpenWorktreeParams, State, SwitchToBranchParams } from './protocol';
import {
@ -78,12 +78,12 @@ export class FocusWebviewProvider implements WebviewProvider {
onFocusChanged(focused: boolean): void {
if (focused) {
// If we are becoming focused, delay it a bit to give the UI time to update
setTimeout(() => void setContext(ContextKeys.FocusFocused, focused), 0);
setTimeout(() => void setContext('gitlens:focus:focused', focused), 0);
return;
}
void setContext(ContextKeys.FocusFocused, focused);
void setContext('gitlens:focus:focused', focused);
}
onMessageReceived(e: IpcMessage) {

+ 2
- 2
src/plus/webviews/focus/registration.ts Näytä tiedosto

@ -1,4 +1,4 @@
import { Commands, ContextKeys } from '../../../constants';
import { Commands } from '../../../constants';
import type { WebviewsController } from '../../../webviews/webviewsController';
import type { State } from './protocol';
@ -7,7 +7,7 @@ export function registerFocusWebviewPanel(controller: WebviewsController) {
fileName: 'focus.html',
iconPath: 'images/gitlens-icon.png',
title: 'Focus View',
contextKeyPrefix: `${ContextKeys.WebviewPrefix}focus`,
contextKeyPrefix: `gitlens:webview:focus`,
trackingFeature: 'focusWebview',
plusFeature: true,
resolveWebviewProvider: async function (container, id, host) {

+ 5
- 5
src/plus/webviews/graph/graphWebview.ts Näytä tiedosto

@ -12,7 +12,8 @@ import type {
} from '../../../commands';
import { parseCommandContext } from '../../../commands/base';
import type { Config } from '../../../config';
import { Commands, ContextKeys, GlyphChars } from '../../../constants';
import type { WebviewIds, WebviewViewIds } from '../../../constants';
import { Commands, GlyphChars } from '../../../constants';
import type { Container } from '../../../container';
import { getContext, onDidChangeContext } from '../../../context';
import type { CommitSelectedEvent } from '../../../eventBus';
@ -73,7 +74,6 @@ import { RepositoryFolderNode } from '../../../views/nodes/viewNode';
import type { IpcMessage, IpcMessageParams, IpcNotificationType } from '../../../webviews/protocol';
import { onIpc } from '../../../webviews/protocol';
import type { WebviewController, WebviewProvider } from '../../../webviews/webviewController';
import type { WebviewIds, WebviewViewIds } from '../../../webviews/webviewsController';
import type { SubscriptionChangeEvent } from '../../subscription/subscriptionService';
import type {
DimMergeCommitsParams,
@ -753,7 +753,7 @@ export class GraphWebviewProvider implements WebviewProvider {
}
private async onGetMissingRefMetadata(e: GetMissingRefsMetadataParams) {
if (this._graph == null || this._refsMetadata === null || !getContext(ContextKeys.HasConnectedRemotes)) return;
if (this._graph == null || this._refsMetadata === null || !getContext('gitlens:hasConnectedRemotes')) return;
const repoPath = this._graph.repoPath;
@ -1379,7 +1379,7 @@ export class GraphWebviewProvider implements WebviewProvider {
repo.startWatchingFileSystem(),
repo.onDidChangeFileSystem(this.onRepositoryFileSystemChanged, this),
onDidChangeContext(key => {
if (key !== ContextKeys.HasConnectedRemotes) return;
if (key !== 'gitlens:hasConnectedRemotes') return;
this.resetRefsMetadata();
this.updateRefsMetadata();
@ -1892,7 +1892,7 @@ export class GraphWebviewProvider implements WebviewProvider {
}
private resetRefsMetadata(): null | undefined {
this._refsMetadata = getContext(ContextKeys.HasConnectedRemotes) ? undefined : null;
this._refsMetadata = getContext('gitlens:hasConnectedRemotes') ? undefined : null;
return this._refsMetadata;
}

+ 3
- 3
src/plus/webviews/graph/registration.ts Näytä tiedosto

@ -1,5 +1,5 @@
import { Disposable } from 'vscode';
import { Commands, ContextKeys } from '../../../constants';
import { Commands } from '../../../constants';
import type { Container } from '../../../container';
import type { Repository } from '../../../git/models/repository';
import { executeCommand, registerCommand } from '../../../system/command';
@ -17,7 +17,7 @@ export function registerGraphWebviewPanel(controller: WebviewsController) {
fileName: 'graph.html',
iconPath: 'images/gitlens-icon.png',
title: 'Commit Graph',
contextKeyPrefix: `${ContextKeys.WebviewPrefix}graph`,
contextKeyPrefix: `gitlens:webview:graph`,
trackingFeature: 'graphWebview',
plusFeature: true,
panelOptions: {
@ -38,7 +38,7 @@ export function registerGraphWebviewView(controller: WebviewsController) {
return controller.registerWebviewView<State>('gitlens.views.graph', {
fileName: 'graph.html',
title: 'Commit Graph',
contextKeyPrefix: `${ContextKeys.WebviewViewPrefix}graph`,
contextKeyPrefix: `gitlens:webviewView:graph`,
trackingFeature: 'graphView',
plusFeature: true,
canResolveWebviewProvider: function (_container, _id) {

+ 3
- 3
src/plus/webviews/graph/statusbar.ts Näytä tiedosto

@ -1,6 +1,6 @@
import type { ConfigurationChangeEvent, StatusBarItem } from 'vscode';
import { Disposable, MarkdownString, StatusBarAlignment, window } from 'vscode';
import { Commands, ContextKeys } from '../../../constants';
import { Commands } from '../../../constants';
import type { Container } from '../../../container';
import { getContext, onDidChangeContext } from '../../../context';
import { configuration } from '../../../system/configuration';
@ -18,7 +18,7 @@ export class GraphStatusBarController implements Disposable {
container.subscription.onDidChange(this.onSubscriptionChanged, this),
once(container.onReady)(() => queueMicrotask(() => this.updateStatusBar())),
onDidChangeContext(key => {
if (key !== ContextKeys.Enabled && key !== ContextKeys.PlusEnabled) return;
if (key !== 'gitlens:enabled' && key !== 'gitlens:plus:enabled') return;
this.updateStatusBar();
}),
{ dispose: () => this._statusBarItem?.dispose() },
@ -41,7 +41,7 @@ export class GraphStatusBarController implements Disposable {
private updateStatusBar() {
const enabled =
configuration.get('graph.statusBar.enabled') && getContext(ContextKeys.Enabled) && arePlusFeaturesEnabled();
configuration.get('graph.statusBar.enabled') && getContext('gitlens:enabled') && arePlusFeaturesEnabled();
if (enabled) {
if (this._statusBarItem == null) {
this._statusBarItem = window.createStatusBarItem('gitlens.graph', StatusBarAlignment.Left, 10000 - 3);

+ 3
- 3
src/plus/webviews/timeline/registration.ts Näytä tiedosto

@ -1,4 +1,4 @@
import { Commands, ContextKeys } from '../../../constants';
import { Commands } from '../../../constants';
import type { WebviewsController } from '../../../webviews/webviewsController';
import type { State } from './protocol';
@ -7,7 +7,7 @@ export function registerTimelineWebviewPanel(controller: WebviewsController) {
fileName: 'timeline.html',
iconPath: 'images/gitlens-icon.png',
title: 'Visual File History',
contextKeyPrefix: `${ContextKeys.WebviewPrefix}timeline`,
contextKeyPrefix: `gitlens:webview:timeline`,
trackingFeature: 'timelineWebview',
plusFeature: true,
resolveWebviewProvider: async function (container, id, host) {
@ -21,7 +21,7 @@ export function registerTimelineWebviewView(controller: WebviewsController) {
return controller.registerWebviewView<State>('gitlens.views.timeline', {
fileName: 'timeline.html',
title: 'Visual File History',
contextKeyPrefix: `${ContextKeys.WebviewViewPrefix}timeline`,
contextKeyPrefix: `gitlens:webviewView:timeline`,
trackingFeature: 'timelineView',
plusFeature: true,
resolveWebviewProvider: async function (container, id, host) {

+ 1
- 1
src/plus/webviews/timeline/timelineWebview.ts Näytä tiedosto

@ -1,5 +1,6 @@
import type { TextEditor, ViewColumn } from 'vscode';
import { commands, Disposable, Uri, window } from 'vscode';
import type { WebviewIds, WebviewViewIds } from '../../../constants';
import { Commands } from '../../../constants';
import type { Container } from '../../../container';
import type { FileSelectedEvent } from '../../../eventBus';
@ -20,7 +21,6 @@ import { hasVisibleTextEditor, isTextEditor } from '../../../system/utils';
import type { IpcMessage } from '../../../webviews/protocol';
import { onIpc } from '../../../webviews/protocol';
import type { WebviewController, WebviewProvider } from '../../../webviews/webviewController';
import type { WebviewIds, WebviewViewIds } from '../../../webviews/webviewsController';
import type { SubscriptionChangeEvent } from '../../subscription/subscriptionService';
import type { Commit, Period, State } from './protocol';
import { DidChangeNotificationType, OpenDataPointCommandType, UpdatePeriodCommandType } from './protocol';

+ 4
- 4
src/system/keyboard.ts Näytä tiedosto

@ -1,5 +1,5 @@
import { Disposable } from 'vscode';
import { commandPrefix, ContextKeys } from '../constants';
import { commandPrefix, keyPrefix } from '../constants';
import { setContext } from '../context';
import { registerCommand } from './command';
import { log } from './decorators/log';
@ -88,7 +88,7 @@ export class KeyboardScope implements Disposable {
}
mapping[key] = undefined;
await setContext(`${ContextKeys.KeyPrefix}${key}`, false);
await setContext(`${keyPrefix}:${key}`, false);
}
@log({
@ -142,12 +142,12 @@ export class KeyboardScope implements Disposable {
mapping[key] = command;
if (!set) {
await setContext(`${ContextKeys.KeyPrefix}${key}`, true);
await setContext(`${keyPrefix}:${key}`, true);
}
}
private async updateKeyCommandsContext(mapping: KeyMapping) {
await Promise.all(keys.map(key => setContext(`${ContextKeys.KeyPrefix}${key}`, Boolean(mapping?.[key]))));
await Promise.all(keys.map(key => setContext(`${keyPrefix}:${key}`, Boolean(mapping?.[key]))));
}
}

+ 1
- 1
src/trackers/documentTracker.ts Näytä tiedosto

@ -112,7 +112,7 @@ export class DocumentTracker implements Disposable {
this._timer = setTimeout(() => {
this._timer = undefined;
void setContext(ContextKeys.ActiveFileStatus, undefined);
void setContext('gitlens:activeFileStatus', undefined);
}, 250);
return;

+ 2
- 3
src/trackers/trackedDocument.ts Näytä tiedosto

@ -1,6 +1,5 @@
import type { Disposable, Event, TextDocument, TextEditor } from 'vscode';
import { EventEmitter } from 'vscode';
import { ContextKeys } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import { GitUri } from '../git/gitUri';
@ -108,7 +107,7 @@ export class TrackedDocument implements Disposable {
if (this._requiresUpdate) {
await this.update();
}
void setContext(ContextKeys.ActiveFileStatus, this.getStatus());
void setContext('gitlens:activeFileStatus', this.getStatus());
}
is(document: TextDocument) {
@ -188,7 +187,7 @@ export class TrackedDocument implements Disposable {
if (active != null) {
const blameable = this.isBlameable;
void setContext(ContextKeys.ActiveFileStatus, this.getStatus());
void setContext('gitlens:activeFileStatus', this.getStatus());
if (!this.initializing && wasBlameable !== blameable) {
const e: DocumentBlameStateChangeEvent<T> = { editor: active, document: this, blameable: blameable };

+ 2
- 2
src/views/commitsView.ts Näytä tiedosto

@ -7,7 +7,7 @@ import type {
import { Disposable, ProgressLocation, ThemeIcon, TreeItem, TreeItemCollapsibleState, window } from 'vscode';
import type { CommitsViewConfig } from '../config';
import { ViewFilesLayout, ViewShowBranchComparison } from '../config';
import { Commands, ContextKeys, GlyphChars } from '../constants';
import { Commands, GlyphChars } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import { GitUri } from '../git/gitUri';
@ -440,7 +440,7 @@ export class CommitsView extends ViewBase {
}
private setMyCommitsOnly(enabled: boolean) {
void setContext(ContextKeys.ViewsCommitsMyCommitsOnly, enabled);
void setContext('gitlens:views:commits:myCommitsOnly', enabled);
this.state.myCommitsOnly = enabled;
void this.refresh(true);
}

+ 5
- 5
src/views/fileHistoryView.ts Näytä tiedosto

@ -1,6 +1,6 @@
import type { ConfigurationChangeEvent, Disposable } from 'vscode';
import type { FileHistoryViewConfig } from '../config';
import { Commands, ContextKeys } from '../constants';
import { Commands } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import type { GitUri } from '../git/gitUri';
@ -22,8 +22,8 @@ export class FileHistoryView extends ViewBase
constructor(container: Container) {
super(container, 'gitlens.views.fileHistory', 'File History', 'fileHistoryView');
void setContext(ContextKeys.ViewsFileHistoryCursorFollowing, this._followCursor);
void setContext(ContextKeys.ViewsFileHistoryEditorFollowing, this._followEditor);
void setContext('gitlens:views:fileHistory:cursorFollowing', this._followCursor);
void setContext('gitlens:views:fileHistory:editorFollowing', this._followEditor);
}
protected override get showCollapseAll(): boolean {
@ -132,7 +132,7 @@ export class FileHistoryView extends ViewBase
const uri = !this._followEditor && this.root?.hasUri ? this.root.uri : undefined;
this._followCursor = enabled;
void setContext(ContextKeys.ViewsFileHistoryCursorFollowing, enabled);
void setContext('gitlens:views:fileHistory:cursorFollowing', enabled);
this.title = this._followCursor ? 'Line History' : 'File History';
@ -150,7 +150,7 @@ export class FileHistoryView extends ViewBase
if (!root.hasUri) return;
this._followEditor = enabled;
void setContext(ContextKeys.ViewsFileHistoryEditorFollowing, enabled);
void setContext('gitlens:views:fileHistory:editorFollowing', enabled);
root.setEditorFollowing(enabled);

+ 3
- 3
src/views/lineHistoryView.ts Näytä tiedosto

@ -1,6 +1,6 @@
import type { ConfigurationChangeEvent, Disposable } from 'vscode';
import type { LineHistoryViewConfig } from '../config';
import { Commands, ContextKeys } from '../constants';
import { Commands } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import { executeCommand } from '../system/command';
@ -17,7 +17,7 @@ export class LineHistoryView extends ViewBase
constructor(container: Container) {
super(container, 'gitlens.views.lineHistory', 'Line History', 'lineHistoryView');
void setContext(ContextKeys.ViewsLineHistoryEditorFollowing, true);
void setContext('gitlens:views:lineHistory:editorFollowing', true);
}
protected override get showCollapseAll(): boolean {
@ -80,7 +80,7 @@ export class LineHistoryView extends ViewBase
const root = this.ensureRoot();
if (!root.hasUri) return;
void setContext(ContextKeys.ViewsLineHistoryEditorFollowing, enabled);
void setContext('gitlens:views:lineHistory:editorFollowing', enabled);
this.root?.setEditorFollowing(enabled);

+ 2
- 2
src/views/nodes/branchNode.ts Näytä tiedosto

@ -1,7 +1,7 @@
import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, window } from 'vscode';
import type { ViewShowBranchComparison } from '../../config';
import { ViewBranchesLayout } from '../../config';
import { Colors, ContextKeys, GlyphChars } from '../../constants';
import { Colors, GlyphChars } from '../../constants';
import { getContext } from '../../context';
import type { GitUri } from '../../git/gitUri';
import type { GitBranch } from '../../git/models/branch';
@ -148,7 +148,7 @@ export class BranchNode
this.view.config.pullRequests.enabled &&
this.view.config.pullRequests.showForBranches &&
(branch.upstream != null || branch.remote) &&
getContext(ContextKeys.HasConnectedRemotes)
getContext('gitlens:hasConnectedRemotes')
) {
pullRequest = this.getState('pullRequest');
if (pullRequest === undefined && this.getState('pendingPullRequest') === undefined) {

+ 2
- 2
src/views/nodes/commitNode.ts Näytä tiedosto

@ -2,7 +2,7 @@ import type { Command } from 'vscode';
import { MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
import type { DiffWithPreviousCommandArgs } from '../../commands';
import { ViewFilesLayout } from '../../config';
import { Colors, Commands, ContextKeys } from '../../constants';
import { Colors, Commands } from '../../constants';
import { getContext } from '../../context';
import { CommitFormatter } from '../../git/formatters/commitFormatter';
import type { GitBranch } from '../../git/models/branch';
@ -81,7 +81,7 @@ export class CommitNode extends ViewRefNode
!(this.view instanceof TagsView) &&
!(this.view instanceof FileHistoryView) &&
!this.unpublished &&
getContext(ContextKeys.HasConnectedRemotes) &&
getContext('gitlens:hasConnectedRemotes') &&
this.view.config.pullRequests.enabled &&
this.view.config.pullRequests.showForCommits
) {

+ 1
- 1
src/views/nodes/fileHistoryTrackerNode.ts Näytä tiedosto

@ -258,6 +258,6 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
setUri(uri?: GitUri) {
this._uri = uri ?? unknownGitUri;
void setContext(ContextKeys.ViewsFileHistoryCanPin, this.hasUri);
void setContext('gitlens:views:fileHistory:canPin', this.hasUri);
}
}

+ 1
- 2
src/views/nodes/lineHistoryTrackerNode.ts Näytä tiedosto

@ -1,6 +1,5 @@
import type { Selection } from 'vscode';
import { TreeItem, TreeItemCollapsibleState, window } from 'vscode';
import { ContextKeys } from '../../constants';
import { setContext } from '../../context';
import type { GitCommitish } from '../../git/gitUri';
import { GitUri, unknownGitUri } from '../../git/gitUri';
@ -257,6 +256,6 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
setUri(uri?: GitUri) {
this._uri = uri ?? unknownGitUri;
void setContext(ContextKeys.ViewsFileHistoryCanPin, this.hasUri);
void setContext('gitlens:views:fileHistory:canPin', this.hasUri);
}
}

+ 2
- 2
src/views/nodes/worktreeNode.ts Näytä tiedosto

@ -1,5 +1,5 @@
import { MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, window } from 'vscode';
import { ContextKeys, GlyphChars } from '../../constants';
import { GlyphChars } from '../../constants';
import { getContext } from '../../context';
import type { GitUri } from '../../git/gitUri';
import type { GitBranch } from '../../git/models/branch';
@ -74,7 +74,7 @@ export class WorktreeNode extends ViewNode
this.view.config.pullRequests.enabled &&
this.view.config.pullRequests.showForBranches &&
(branch.upstream != null || branch.remote) &&
getContext(ContextKeys.HasConnectedRemotes)
getContext('gitlens:hasConnectedRemotes')
) {
pullRequest = this.getState('pullRequest');
if (pullRequest === undefined && this.getState('pendingPullRequest') === undefined) {

+ 2
- 2
src/views/repositoriesView.ts Näytä tiedosto

@ -2,7 +2,7 @@ import type { CancellationToken, ConfigurationChangeEvent, Disposable, Event } f
import { EventEmitter, ProgressLocation, window } from 'vscode';
import type { RepositoriesViewConfig } from '../config';
import { ViewBranchesLayout, ViewFilesLayout, ViewShowBranchComparison } from '../config';
import { Commands, ContextKeys } from '../constants';
import { Commands } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import { getRemoteNameFromBranchName } from '../git/models/branch';
@ -851,7 +851,7 @@ export class RepositoriesView extends ViewBase
}
}
void setContext(ContextKeys.ViewsRepositoriesAutoRefresh, enabled && workspaceEnabled);
void setContext('gitlens:views:repositories:autoRefresh', enabled && workspaceEnabled);
this._onDidChangeAutoRefresh.fire();
}

+ 5
- 5
src/views/searchAndCompareView.ts Näytä tiedosto

@ -2,7 +2,7 @@ import type { ConfigurationChangeEvent, Disposable } from 'vscode';
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import type { SearchAndCompareViewConfig } from '../config';
import { ViewFilesLayout } from '../config';
import { Commands, ContextKeys } from '../constants';
import { Commands } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import { unknownGitUri } from '../git/gitUri';
@ -213,7 +213,7 @@ export class SearchAndCompareViewNode extends ViewNode {
ref: ref,
});
this.children.unshift(this.comparePicker);
void setContext(ContextKeys.ViewsCanCompare, true);
void setContext('gitlens:views:canCompare', true);
await this.triggerChange();
@ -231,7 +231,7 @@ export class SearchAndCompareViewNode extends ViewNode {
}
private removeComparePicker(silent: boolean = false) {
void setContext(ContextKeys.ViewsCanCompare, false);
void setContext('gitlens:views:canCompare', false);
if (this.comparePicker != null) {
const index = this.children.indexOf(this.comparePicker);
if (index !== -1) {
@ -251,7 +251,7 @@ export class SearchAndCompareView extends ViewBase
constructor(container: Container) {
super(container, 'gitlens.views.searchAndCompare', 'Search & Compare', 'searchAndCompareView');
void setContext(ContextKeys.ViewsSearchAndCompareKeepResults, this.keepResults);
void setContext('gitlens:views:searchAndCompare:keepResults', this.keepResults);
}
protected getRoot() {
@ -537,7 +537,7 @@ export class SearchAndCompareView extends ViewBase
private setKeepResults(enabled: boolean) {
void this.container.storage.storeWorkspace('views:searchAndCompare:keepResults', enabled);
void setContext(ContextKeys.ViewsSearchAndCompareKeepResults, enabled);
void setContext('gitlens:views:searchAndCompare:keepResults', enabled);
}
private setShowAvatars(enabled: boolean) {

+ 3
- 3
src/views/viewCommands.ts Näytä tiedosto

@ -8,7 +8,7 @@ import type {
OpenFileAtRevisionCommandArgs,
} from '../commands';
import { FileAnnotationType, ViewShowBranchComparison } from '../config';
import { Commands, ContextKeys } from '../constants';
import { Commands } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import { browseAtRevision } from '../git/actions';
@ -938,7 +938,7 @@ export class ViewCommands {
const selected = this._selectedFile;
this._selectedFile = undefined;
void setContext(ContextKeys.ViewsCanCompareFile, false);
void setContext('gitlens:views:canCompare:file', false);
return executeCommand<DiffWithCommandArgs>(Commands.DiffWith, {
repoPath: selected.repoPath,
@ -964,7 +964,7 @@ export class ViewCommands {
repoPath: node.repoPath,
uri: node.uri,
};
void setContext(ContextKeys.ViewsCanCompareFile, true);
void setContext('gitlens:views:canCompare:file', true);
}
@debug()

+ 7
- 7
src/vsls/vsls.ts Näytä tiedosto

@ -1,6 +1,6 @@
import { Disposable, extensions, workspace } from 'vscode';
import type { LiveShare, LiveShareExtension, SessionChangeEvent } from '../@types/vsls';
import { ContextKeys, Schemes } from '../constants';
import { Schemes } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import { configuration } from '../system/configuration';
@ -68,14 +68,14 @@ export class VslsController implements Disposable {
this._api = this.getLiveShareApi();
const api = await this._api;
if (api == null) {
void setContext(ContextKeys.Vsls, false);
void setContext('gitlens:vsls', false);
// Tear it down if we can't talk to live share
this._ready.fulfill();
return;
}
void setContext(ContextKeys.Vsls, true);
void setContext('gitlens:vsls', true);
this._disposable = Disposable.from(
this._disposable,
@ -97,7 +97,7 @@ export class VslsController implements Disposable {
switch (e.session.role) {
case 1 /*Role.Host*/:
this.setReadonly(false);
void setContext(ContextKeys.Vsls, 'host');
void setContext('gitlens:vsls', 'host');
if (configuration.get('liveshare.allowGuestAccess')) {
this._host = await VslsHostService.share(api, this.container);
}
@ -108,7 +108,7 @@ export class VslsController implements Disposable {
case 2 /*Role.Guest*/:
this.setReadonly(true);
void setContext(ContextKeys.Vsls, 'guest');
void setContext('gitlens:vsls', 'guest');
this._guest = await VslsGuestService.connect(api, this.container);
this._ready.fulfill();
@ -117,7 +117,7 @@ export class VslsController implements Disposable {
default:
this.setReadonly(false);
void setContext(ContextKeys.Vsls, true);
void setContext('gitlens:vsls', true);
this._ready = defer<void>();
@ -145,7 +145,7 @@ export class VslsController implements Disposable {
}
private setReadonly(value: boolean) {
this._readonly = value;
void setContext(ContextKeys.Readonly, value ? true : undefined);
void setContext('gitlens:readonly', value ? true : undefined);
}
async guest() {

+ 3
- 4
src/webviews/commitDetails/commitDetailsWebview.ts Näytä tiedosto

@ -2,8 +2,8 @@ import type { CancellationToken, ConfigurationChangeEvent, TextDocumentShowOptio
import { CancellationTokenSource, Disposable, Uri, ViewColumn, window } from 'vscode';
import { serializeAutolink } from '../../annotations/autolinks';
import type { CopyShaToClipboardCommandArgs } from '../../commands';
import type { CoreConfiguration } from '../../constants';
import { Commands, ContextKeys } from '../../constants';
import type { CoreConfiguration, WebviewIds, WebviewViewIds } from '../../constants';
import { Commands } from '../../constants';
import type { Container } from '../../container';
import { getContext } from '../../context';
import type { CommitSelectedEvent } from '../../eventBus';
@ -46,7 +46,6 @@ import type { LinesChangeEvent } from '../../trackers/lineTracker';
import type { IpcMessage } from '../protocol';
import { onIpc } from '../protocol';
import type { WebviewController, WebviewProvider } from '../webviewController';
import type { WebviewIds, WebviewViewIds } from '../webviewsController';
import type { CommitDetails, FileActionParams, Preferences, State } from './protocol';
import {
AutolinkSettingsCommandType,
@ -519,7 +518,7 @@ export class CommitDetailsWebviewProvider implements WebviewProvider
this.updatePendingContext(
{
commit: commit,
richStateLoaded: Boolean(commit?.isUncommitted) || !getContext(ContextKeys.HasConnectedRemotes),
richStateLoaded: Boolean(commit?.isUncommitted) || !getContext('gitlens:hasConnectedRemotes'),
formattedMessage: undefined,
autolinkedIssues: undefined,
pullRequest: undefined,

+ 1
- 2
src/webviews/commitDetails/registration.ts Näytä tiedosto

@ -1,4 +1,3 @@
import { ContextKeys } from '../../constants';
import type { Serialized } from '../../system/serialize';
import type { WebviewsController } from '../webviewsController';
import type { State } from './protocol';
@ -7,7 +6,7 @@ export function registerCommitDetailsWebviewView(controller: WebviewsController)
return controller.registerWebviewView<State, Serialized<State>>('gitlens.views.commitDetails', {
fileName: 'commitDetails.html',
title: 'Commit Details',
contextKeyPrefix: `${ContextKeys.WebviewViewPrefix}commitDetails`,
contextKeyPrefix: `gitlens:webviewView:commitDetails`,
trackingFeature: 'commitDetailsView',
plusFeature: false,
resolveWebviewProvider: async function (container, id, host) {

+ 3
- 4
src/webviews/home/homeWebview.ts Näytä tiedosto

@ -2,7 +2,7 @@ import type { ConfigurationChangeEvent } from 'vscode';
import { Disposable, window } from 'vscode';
import { getAvatarUriFromGravatarEmail } from '../../avatars';
import { ViewsLayout } from '../../commands/setViewsLayout';
import { ContextKeys } from '../../constants';
import type { WebviewIds, WebviewViewIds } from '../../constants';
import type { Container } from '../../container';
import { getContext, onDidChangeContext } from '../../context';
import type { RepositoriesVisibility } from '../../git/gitProviderService';
@ -16,7 +16,6 @@ import { debounce } from '../../system/function';
import type { IpcMessage } from '../protocol';
import { onIpc } from '../protocol';
import type { WebviewController, WebviewProvider } from '../webviewController';
import type { WebviewIds, WebviewViewIds } from '../webviewsController';
import type { CompleteStepParams, DismissBannerParams, DismissSectionParams, State } from './protocol';
import {
CompletedActions,
@ -41,7 +40,7 @@ export class HomeWebviewProvider implements WebviewProvider {
this._disposable = Disposable.from(
this.container.subscription.onDidChange(this.onSubscriptionChanged, this),
onDidChangeContext(key => {
if (key !== ContextKeys.Disabled) return;
if (key !== 'gitlens:disabled') return;
this.notifyExtensionEnabled();
}),
configuration.onDidChange(e => {
@ -262,7 +261,7 @@ export class HomeWebviewProvider implements WebviewProvider {
}
private getExtensionEnabled() {
return !getContext(ContextKeys.Disabled, false);
return !getContext('gitlens:disabled', false);
}
private notifyExtensionEnabled() {

+ 1
- 2
src/webviews/home/registration.ts Näytä tiedosto

@ -1,4 +1,3 @@
import { ContextKeys } from '../../constants';
import type { WebviewsController } from '../webviewsController';
import type { State } from './protocol';
@ -6,7 +5,7 @@ export function registerHomeWebviewView(controller: WebviewsController) {
return controller.registerWebviewView<State>('gitlens.views.home', {
fileName: 'home.html',
title: 'Home',
contextKeyPrefix: `${ContextKeys.WebviewViewPrefix}home`,
contextKeyPrefix: `gitlens:webviewView:home`,
trackingFeature: 'homeView',
plusFeature: false,
resolveWebviewProvider: async function (container, id, host) {

+ 1
- 1
src/webviews/rebase/rebaseEditor.ts Näytä tiedosto

@ -134,7 +134,7 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
}
private get contextKeyPrefix() {
return `${ContextKeys.WebviewPrefix}rebaseEditor` as const;
return `gitlens:webview:rebaseEditor` as const;
}
get enabled(): boolean {

+ 1
- 1
src/webviews/settings/registration.ts Näytä tiedosto

@ -9,7 +9,7 @@ export function registerSettingsWebviewPanel(controller: WebviewsController) {
fileName: 'settings.html',
iconPath: 'images/gitlens-icon.png',
title: 'GitLens Settings',
contextKeyPrefix: `${ContextKeys.WebviewPrefix}settings`,
contextKeyPrefix: `gitlens:webview:settings`,
trackingFeature: 'settingsWebview',
plusFeature: false,
resolveWebviewProvider: async function (container, id, host) {

+ 9
- 28
src/webviews/webviewController.ts Näytä tiedosto

@ -8,8 +8,7 @@ import type {
} from 'vscode';
import { EventEmitter, Uri, ViewColumn, window, workspace } from 'vscode';
import { getNonce } from '@env/crypto';
import type { Commands } from '../constants';
import { ContextKeys } from '../constants';
import type { Commands, CustomEditorIds, WebviewIds, WebviewViewIds } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import { executeCommand } from '../system/command';
@ -18,13 +17,7 @@ import { serialize } from '../system/decorators/serialize';
import type { TrackedUsageFeatures } from '../telemetry/usageTracker';
import type { IpcMessage, IpcMessageParams, IpcNotificationType, WebviewFocusChangedParams } from './protocol';
import { ExecuteCommandType, onIpc, WebviewFocusChangedCommandType, WebviewReadyCommandType } from './protocol';
import type {
CustomEditorIds,
WebviewIds,
WebviewPanelDescriptor,
WebviewViewDescriptor,
WebviewViewIds,
} from './webviewsController';
import type { WebviewPanelDescriptor, WebviewViewDescriptor } from './webviewsController';
const maxSmallIntegerV8 = 2 ** 30; // Max number that can be stored in V8's smis (small integers)
const utf8TextDecoder = new TextDecoder('utf8');
@ -145,9 +138,7 @@ export class WebviewController implements Dispos
public readonly parent: WebviewPanel | WebviewView,
title: string,
private readonly fileName: string,
private readonly contextKeyPrefix:
| `${ContextKeys.WebviewPrefix}${WebviewIds}`
| `${ContextKeys.WebviewViewPrefix}${WebviewViewIds}`,
private readonly contextKeyPrefix: `gitlens:webview:${WebviewIds}` | `gitlens:webviewView:${WebviewViewIds}`,
private readonly trackingFeature: TrackedUsageFeatures,
resolveProvider: (
host: WebviewController<State, SerializedState>,
@ -501,34 +492,24 @@ export function replaceWebviewHtmlTokens(
}
export function resetContextKeys(
contextKeyPrefix:
| `${ContextKeys.WebviewPrefix}${WebviewIds | CustomEditorIds}`
| `${ContextKeys.WebviewViewPrefix}${WebviewViewIds}`,
contextKeyPrefix: `gitlens:webview:${WebviewIds | CustomEditorIds}` | `gitlens:webviewView:${WebviewViewIds}`,
): void {
void setContext(`${contextKeyPrefix}:inputFocus`, false);
void setContext(`${contextKeyPrefix}:focus`, false);
if (contextKeyPrefix.startsWith(ContextKeys.WebviewPrefix)) {
void setContext(
`${contextKeyPrefix as `${ContextKeys.WebviewPrefix}${WebviewIds | CustomEditorIds}`}:active`,
false,
);
if (contextKeyPrefix.startsWith('gitlens:webview:')) {
void setContext(`${contextKeyPrefix as `gitlens:webview:${WebviewIds | CustomEditorIds}`}:active`, false);
}
}
export function setContextKeys(
contextKeyPrefix:
| `${ContextKeys.WebviewPrefix}${WebviewIds | CustomEditorIds}`
| `${ContextKeys.WebviewViewPrefix}${WebviewViewIds}`,
contextKeyPrefix: `gitlens:webview:${WebviewIds | CustomEditorIds}` | `gitlens:webviewView:${WebviewViewIds}`,
active?: boolean,
focus?: boolean,
inputFocus?: boolean,
): void {
if (contextKeyPrefix.startsWith(ContextKeys.WebviewPrefix)) {
if (contextKeyPrefix.startsWith('gitlens:webview:')) {
if (active != null) {
void setContext(
`${contextKeyPrefix as `${ContextKeys.WebviewPrefix}${WebviewIds | CustomEditorIds}`}:active`,
active,
);
void setContext(`${contextKeyPrefix as `gitlens:webview:${WebviewIds | CustomEditorIds}`}:active`, active);
if (!active) {
focus = false;

+ 1
- 2
src/webviews/webviewWithConfigBase.ts Näytä tiedosto

@ -1,6 +1,6 @@
import type { ConfigurationChangeEvent } from 'vscode';
import { ConfigurationTarget, Disposable } from 'vscode';
import type { CoreConfiguration } from '../constants';
import type { CoreConfiguration, WebviewIds, WebviewViewIds } from '../constants';
import type { Container } from '../container';
import { CommitFormatter } from '../git/formatters/commitFormatter';
import { GitCommit, GitCommitIdentity } from '../git/models/commit';
@ -20,7 +20,6 @@ import {
UpdateConfigurationCommandType,
} from './protocol';
import type { WebviewController, WebviewProvider } from './webviewController';
import type { WebviewIds, WebviewViewIds } from './webviewsController';
export abstract class WebviewProviderWithConfigBase<State> implements WebviewProvider<State> {
private readonly _disposable: Disposable;

+ 3
- 7
src/webviews/webviewsController.ts Näytä tiedosto

@ -6,7 +6,7 @@ import type {
WebviewViewResolveContext,
} from 'vscode';
import { Disposable, Uri, ViewColumn, window } from 'vscode';
import type { Commands, ContextKeys } from '../constants';
import type { Commands, WebviewIds, WebviewViewIds } from '../constants';
import type { Container } from '../container';
import { ensurePlusFeaturesEnabled } from '../plus/subscription/utils';
import { executeCommand, registerCommand } from '../system/command';
@ -14,15 +14,11 @@ import type { TrackedUsageFeatures } from '../telemetry/usageTracker';
import type { WebviewProvider } from './webviewController';
import { WebviewController } from './webviewController';
export type CustomEditorIds = 'rebaseEditor';
export type WebviewIds = 'graph' | 'settings' | 'timeline' | 'welcome' | 'focus';
export type WebviewViewIds = 'commitDetails' | 'graph' | 'home' | 'timeline';
export interface WebviewPanelDescriptor<State = any, SerializedState = State> {
readonly fileName: string;
readonly iconPath: string;
readonly title: string;
readonly contextKeyPrefix: `${ContextKeys.WebviewPrefix}${WebviewIds}`;
readonly contextKeyPrefix: `gitlens:webview:${WebviewIds}`;
readonly trackingFeature: TrackedUsageFeatures;
readonly plusFeature: boolean;
readonly options?: WebviewOptions;
@ -42,7 +38,7 @@ export interface WebviewPanelDescriptor {
export interface WebviewViewDescriptor<State = any, SerializedState = State> {
readonly fileName: string;
readonly title: string;
readonly contextKeyPrefix: `${ContextKeys.WebviewViewPrefix}${WebviewViewIds}`;
readonly contextKeyPrefix: `gitlens:webviewView:${WebviewViewIds}`;
readonly trackingFeature: TrackedUsageFeatures;
readonly plusFeature: boolean;
readonly options?: WebviewOptions;

+ 1
- 1
src/webviews/welcome/registration.ts Näytä tiedosto

@ -7,7 +7,7 @@ export function registerWelcomeWebviewPanel(controller: WebviewsController) {
fileName: 'welcome.html',
iconPath: 'images/gitlens-icon.png',
title: 'Welcome to GitLens',
contextKeyPrefix: `${ContextKeys.WebviewPrefix}welcome`,
contextKeyPrefix: `gitlens:webview:welcome`,
trackingFeature: 'welcomeWebview',
plusFeature: false,
resolveWebviewProvider: async function (container, id, host) {

Ladataan…
Peruuta
Tallenna