diff --git a/src/codelens/codeLensProvider.ts b/src/codelens/codeLensProvider.ts index c4e4904..e49bac6 100644 --- a/src/codelens/codeLensProvider.ts +++ b/src/codelens/codeLensProvider.ts @@ -20,7 +20,7 @@ import type { } from '../commands'; import type { CodeLensConfig, CodeLensLanguageScope } from '../config'; import { CodeLensCommand, CodeLensScopes, FileAnnotationType } from '../config'; -import { Commands, CoreCommands, Schemes } from '../constants'; +import { Commands, Schemes } from '../constants'; import type { Container } from '../container'; import type { GitUri } from '../git/gitUri'; import type { GitBlame, GitBlameLines } from '../git/models/blame'; @@ -150,7 +150,7 @@ export class GitCodeLensProvider implements CodeLensProvider { [blame, symbols] = await Promise.all([ this.container.git.getBlame(gitUri, document), executeCoreCommand<[Uri], SymbolInformation[]>( - CoreCommands.ExecuteDocumentSymbolProvider, + 'vscode.executeDocumentSymbolProvider', document.uri, ), ]); @@ -161,10 +161,7 @@ export class GitCodeLensProvider implements CodeLensProvider { let tracked; [tracked, symbols] = await Promise.all([ this.container.git.isTracked(gitUri), - executeCoreCommand<[Uri], SymbolInformation[]>( - CoreCommands.ExecuteDocumentSymbolProvider, - document.uri, - ), + executeCoreCommand<[Uri], SymbolInformation[]>('vscode.executeDocumentSymbolProvider', document.uri), ]); if (!tracked) return lenses; diff --git a/src/commands/browseRepoAtRevision.ts b/src/commands/browseRepoAtRevision.ts index b2d2994..3e18832 100644 --- a/src/commands/browseRepoAtRevision.ts +++ b/src/commands/browseRepoAtRevision.ts @@ -1,5 +1,5 @@ import type { TextEditor, Uri } from 'vscode'; -import { Commands, CoreCommands } from '../constants'; +import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { showGenericErrorMessage } from '../messages'; @@ -70,7 +70,7 @@ export class BrowseRepoAtRevisionCommand extends ActiveEditorCommand { }); if (!args.openInNewWindow) { - void executeCoreCommand(CoreCommands.FocusFilesExplorer); + void executeCoreCommand('workbench.files.action.focusFilesExplorer'); } } catch (ex) { Logger.error(ex, 'BrowseRepoAtRevisionCommand'); diff --git a/src/commands/diffWith.ts b/src/commands/diffWith.ts index 6bfbd48..2001933 100644 --- a/src/commands/diffWith.ts +++ b/src/commands/diffWith.ts @@ -1,6 +1,6 @@ import type { TextDocumentShowOptions, Uri } from 'vscode'; import { Range, ViewColumn } from 'vscode'; -import { Commands, CoreCommands, GlyphChars } from '../constants'; +import { Commands, GlyphChars } from '../constants'; import type { Container } from '../container'; import type { GitCommit } from '../git/models/commit'; import { isCommit } from '../git/models/commit'; @@ -180,7 +180,7 @@ export class DiffWithCommand extends Command { } void (await executeCoreCommand( - CoreCommands.Diff, + 'vscode.diff', lhs ?? this.container.git.getRevisionUri(deletedOrMissing, args.lhs.uri.fsPath, args.repoPath), rhs ?? this.container.git.getRevisionUri(deletedOrMissing, args.rhs.uri.fsPath, args.repoPath), title, diff --git a/src/commands/generateCommitMessage.ts b/src/commands/generateCommitMessage.ts index 50c8476..0d3d794 100644 --- a/src/commands/generateCommitMessage.ts +++ b/src/commands/generateCommitMessage.ts @@ -1,7 +1,7 @@ import type { Disposable, MessageItem, QuickInputButton, TextEditor } from 'vscode'; import { env, ProgressLocation, ThemeIcon, Uri, window } from 'vscode'; import { fetch } from '@env/fetch'; -import { Commands, CoreCommands } from '../constants'; +import { Commands } from '../constants'; import type { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { uncommittedStaged } from '../git/models/constants'; @@ -172,7 +172,7 @@ export class GenerateCommitMessageCommand extends ActiveEditorCommand { const completion: OpenAIChatCompletionResponse = await rsp.json(); - void executeCoreCommand(CoreCommands.ShowSCM); + void executeCoreCommand('workbench.view.scm'); const message = completion.choices[0].message.content.trim(); scmRepo.inputBox.value = `${currentMessage ? `${currentMessage}\n\n` : ''}${message}`; diff --git a/src/commands/git/coauthors.ts b/src/commands/git/coauthors.ts index 9fe2ce7..cc8b143 100644 --- a/src/commands/git/coauthors.ts +++ b/src/commands/git/coauthors.ts @@ -1,4 +1,3 @@ -import { CoreCommands } from '../../constants'; import type { Container } from '../../container'; import type { GitContributor } from '../../git/models/contributor'; import type { Repository } from '../../git/models/repository'; @@ -85,7 +84,7 @@ export class CoAuthorsGitCommand extends QuickCommand { } repo.inputBox.value = message; - void (await executeCoreCommand(CoreCommands.ShowSCM)); + void (await executeCoreCommand('workbench.view.scm')); } protected async *steps(state: PartialStepState): StepGenerator { diff --git a/src/commands/refreshHover.ts b/src/commands/refreshHover.ts index 1d9065b..d50b748 100644 --- a/src/commands/refreshHover.ts +++ b/src/commands/refreshHover.ts @@ -1,4 +1,4 @@ -import { Commands, CoreCommands } from '../constants'; +import { Commands } from '../constants'; import type { Container } from '../container'; import { command, executeCoreCommand } from '../system/command'; import { Command } from './base'; @@ -11,6 +11,6 @@ export class RefreshHoverCommand extends Command { async execute() { // TODO@eamodio figure out how to really refresh/update a hover - await executeCoreCommand(CoreCommands.EditorShowHover); + await executeCoreCommand('editor.action.showHover'); } } diff --git a/src/commands/setViewsLayout.ts b/src/commands/setViewsLayout.ts index 6fcfd45..5e754c1 100644 --- a/src/commands/setViewsLayout.ts +++ b/src/commands/setViewsLayout.ts @@ -1,6 +1,6 @@ import { window } from 'vscode'; import { viewsConfigKeys } from '../config'; -import { Commands, CoreCommands } from '../constants'; +import { Commands } from '../constants'; import type { Container } from '../container'; import { command, executeCommand, executeCoreCommand } from '../system/command'; import { Command } from './base'; @@ -57,7 +57,7 @@ export class SetViewsLayoutCommand extends Command { // Because of https://github.com/microsoft/vscode/issues/105774, run the command twice which seems to fix things let count = 0; while (count++ < 2) { - void (await executeCoreCommand(CoreCommands.MoveViews, { + void (await executeCoreCommand('vscode.moveViews', { viewIds: views.map(v => `gitlens.views.${v}`), destinationId: 'workbench.view.extension.gitlens', })); @@ -70,7 +70,7 @@ export class SetViewsLayoutCommand extends Command { // Because of https://github.com/microsoft/vscode/issues/105774, run the command twice which seems to fix things let count = 0; while (count++ < 2) { - void (await executeCoreCommand(CoreCommands.MoveViews, { + void (await executeCoreCommand('vscode.moveViews', { viewIds: views.map(v => `gitlens.views.${v}`), destinationId: 'workbench.view.scm', })); diff --git a/src/constants.ts b/src/constants.ts index 47f0319..6123bc8 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -319,45 +319,43 @@ export const enum ContextKeys { PlusState = 'gitlens:plus:state', } -export const enum CoreCommands { - CloseActiveEditor = 'workbench.action.closeActiveEditor', - CloseAllEditors = 'workbench.action.closeAllEditors', - CursorMove = 'cursorMove', - CustomEditorShowFindWidget = 'editor.action.webvieweditor.showFind', - Diff = 'vscode.diff', - EditorScroll = 'editorScroll', - EditorShowHover = 'editor.action.showHover', - ExecuteDocumentSymbolProvider = 'vscode.executeDocumentSymbolProvider', - ExecuteCodeLensProvider = 'vscode.executeCodeLensProvider', - FocusFilesExplorer = 'workbench.files.action.focusFilesExplorer', - InstallExtension = 'workbench.extensions.installExtension', - MoveViews = 'vscode.moveViews', - Open = 'vscode.open', - OpenFolder = 'vscode.openFolder', - OpenInTerminal = 'openInTerminal', - OpenWalkthrough = 'workbench.action.openWalkthrough', - OpenWith = 'vscode.openWith', - NextEditor = 'workbench.action.nextEditor', - PreviewHtml = 'vscode.previewHtml', - RevealLine = 'revealLine', - RevealInExplorer = 'revealInExplorer', - RevealInFileExplorer = 'revealFileInOS', - SetContext = 'setContext', - ShowExplorer = 'workbench.view.explorer', - ShowReferences = 'editor.action.showReferences', - ShowSCM = 'workbench.view.scm', - UninstallExtension = 'workbench.extensions.uninstallExtension', -} +export type CoreCommands = + | 'cursorMove' + | 'editor.action.showHover' + | 'editor.action.showReferences' + | 'editor.action.webvieweditor.showFind' + | 'editorScroll' + | 'openInTerminal' + | 'revealFileInOS' + | 'revealInExplorer' + | 'revealLine' + | 'setContext' + | 'vscode.open' + | 'vscode.openFolder' + | 'vscode.openWith' + | 'vscode.diff' + | 'vscode.executeCodeLensProvider' + | 'vscode.executeDocumentSymbolProvider' + | 'vscode.moveViews' + | 'vscode.previewHtml' + | 'workbench.action.closeActiveEditor' + | 'workbench.action.openWalkthrough' + | 'workbench.action.closeAllEditors' + | 'workbench.action.nextEditor' + | 'workbench.extensions.installExtension' + | 'workbench.extensions.uninstallExtension' + | 'workbench.files.action.focusFilesExplorer' + | 'workbench.view.explorer' + | 'workbench.view.scm'; -export const enum CoreGitCommands { - Publish = 'git.publish', - Pull = 'git.pull', - PullRebase = 'git.pullRebase', - Push = 'git.push', - PushForce = 'git.pushForce', - UndoCommit = 'git.undoCommit', - Fetch = 'git.fetch', -} +export type CoreGitCommands = + | 'git.fetch' + | 'git.publish' + | 'git.pull' + | 'git.pullRebase' + | 'git.push' + | 'git.pushForce' + | 'git.undoCommit'; export const enum CoreGitConfiguration { AutoRepositoryDetection = 'git.autoRepositoryDetection', diff --git a/src/context.ts b/src/context.ts index 14019ed..cd232fc 100644 --- a/src/context.ts +++ b/src/context.ts @@ -1,6 +1,6 @@ -import { commands, EventEmitter } from 'vscode'; +import { EventEmitter } from 'vscode'; import type { ContextKeys } from './constants'; -import { CoreCommands } from './constants'; +import { executeCoreCommand } from './system/command'; import type { WebviewIds, WebviewViewIds } from './webviews/webviewsController'; const contextStorage = new Map(); @@ -35,6 +35,6 @@ export function getContext(key: AllContextKeys, defaultValue?: T): T | undefi export async function setContext(key: AllContextKeys, value: unknown): Promise { contextStorage.set(key, value); - void (await commands.executeCommand(CoreCommands.SetContext, key, value)); + void (await executeCoreCommand('setContext', key, value)); _onDidChangeContext.fire(key); } diff --git a/src/extension.ts b/src/extension.ts index dda564a..6279986 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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, CoreCommands } from './constants'; +import { Commands, ContextKeys } from './constants'; import { Container } from './container'; import { setContext } from './context'; import { isGitUri } from './git/gitUri'; @@ -351,5 +351,5 @@ async function showWelcomeOrWhatsNew(container: Container, version: string, prev function uninstallDeprecatedAuthentication() { if (extensions.getExtension('gitkraken.gitkraken-authentication') == null) return; - void executeCoreCommand(CoreCommands.UninstallExtension, 'gitkraken.gitkraken-authentication'); + void executeCoreCommand('workbench.extensions.uninstallExtension', 'gitkraken.gitkraken-authentication'); } diff --git a/src/git/actions/worktree.ts b/src/git/actions/worktree.ts index a2f5b95..2b373f1 100644 --- a/src/git/actions/worktree.ts +++ b/src/git/actions/worktree.ts @@ -1,6 +1,5 @@ import type { Uri } from 'vscode'; import type { WorktreeGitCommandArgs } from '../../commands/git/worktree'; -import { CoreCommands } from '../../constants'; import { Container } from '../../container'; import { ensure } from '../../system/array'; import { executeCoreCommand } from '../../system/command'; @@ -67,7 +66,7 @@ export async function reveal( } export async function revealInFileExplorer(worktree: GitWorktree) { - void (await executeCoreCommand(CoreCommands.RevealInFileExplorer, worktree.uri)); + void (await executeCoreCommand('revealInExplorer', worktree.uri)); } type OpenFlagsArray = Extract>, { subcommand: 'open' }>['flags']; diff --git a/src/git/models/repository.ts b/src/git/models/repository.ts index c205ffc..0d3addc 100644 --- a/src/git/models/repository.ts +++ b/src/git/models/repository.ts @@ -3,7 +3,7 @@ import { Disposable, EventEmitter, ProgressLocation, RelativePattern, Uri, windo import { md5 } from '@env/crypto'; import { ForcePushMode } from '../../@types/vscode.git.enums'; import type { CreatePullRequestActionContext } from '../../api/gitlens'; -import { CoreGitCommands, CoreGitConfiguration, Schemes } from '../../constants'; +import { CoreGitConfiguration, Schemes } from '../../constants'; import type { Container } from '../../container'; import type { FeatureAccess, Features, PlusFeatures } from '../../features'; import { showCreatePullRequestPrompt, showGenericErrorMessage } from '../../messages'; @@ -580,7 +580,7 @@ export class Repository implements Disposable { if (options?.branch != null) { await this.container.git.fetch(this.path, options); } else { - void (await executeCoreGitCommand(CoreGitCommands.Fetch, this.path)); + void (await executeCoreGitCommand('git.fetch', this.path)); } this.fireChange(RepositoryChange.Unknown); @@ -803,10 +803,7 @@ export class Repository implements Disposable { try { const upstream = await this.hasUpstreamBranch(); if (upstream) { - void (await executeCoreGitCommand( - options?.rebase ? CoreGitCommands.PullRebase : CoreGitCommands.Pull, - this.path, - )); + void (await executeCoreGitCommand(options?.rebase ? 'git.pullRebase' : 'git.pull', this.path)); } else if (configuration.getAny(CoreGitConfiguration.FetchOnPull, Uri.file(this.path))) { await this.container.git.fetch(this.path); } @@ -913,10 +910,7 @@ export class Repository implements Disposable { options?.force ? ForcePushMode.ForceWithLease : undefined, ); } else { - void (await executeCoreGitCommand( - options?.force ? CoreGitCommands.PushForce : CoreGitCommands.Push, - this.path, - )); + void (await executeCoreGitCommand(options?.force ? 'git.pushForce' : 'git.push', this.path)); } this.fireChange(RepositoryChange.Unknown); diff --git a/src/hovers/hovers.ts b/src/hovers/hovers.ts index ba99ed0..36f99ab 100644 --- a/src/hovers/hovers.ts +++ b/src/hovers/hovers.ts @@ -347,7 +347,7 @@ async function getAutoLinkedIssuesOrPullRequests(message: string, remotes: GitRe // scope, // `${GlyphChars.Dot} ${count} issue/pull request queries completed; refreshing...`, // ); - // void executeCoreCommand(CoreCommands.EditorShowHover); + // void executeCoreCommand('editor.action.showHover'); // }); return autolinks; diff --git a/src/partners.ts b/src/partners.ts index cdfc572..4be6fa2 100644 --- a/src/partners.ts +++ b/src/partners.ts @@ -2,7 +2,7 @@ import type { CancellationTokenSource, Extension, ExtensionContext, Uri } from ' import { extensions } from 'vscode'; import type { ActionContext, HoverCommandsActionContext } from './api/gitlens'; import type { InviteToLiveShareCommandArgs } from './commands'; -import { Commands, CoreCommands } from './constants'; +import { Commands } from './constants'; import { Container } from './container'; import { executeCommand, executeCoreCommand } from './system/command'; import type { ContactPresence } from './vsls/vsls'; @@ -36,7 +36,7 @@ export async function installExtension( }); }); - await executeCoreCommand(CoreCommands.InstallExtension, vsix ?? extensionId); + await executeCoreCommand('workbench.extensions.installExtension', vsix ?? extensionId); // Wait for extension activation until timeout expires timer = setTimeout(() => { timer = undefined; diff --git a/src/plus/webviews/graph/graphWebview.ts b/src/plus/webviews/graph/graphWebview.ts index 9572b47..b62e102 100644 --- a/src/plus/webviews/graph/graphWebview.ts +++ b/src/plus/webviews/graph/graphWebview.ts @@ -12,7 +12,7 @@ import type { } from '../../../commands'; import { parseCommandContext } from '../../../commands/base'; import type { Config } from '../../../config'; -import { Commands, ContextKeys, CoreCommands, CoreGitCommands, GlyphChars } from '../../../constants'; +import { Commands, ContextKeys, GlyphChars } from '../../../constants'; import type { Container } from '../../../container'; import { getContext, onDidChangeContext } from '../../../context'; import type { CommitSelectedEvent } from '../../../eventBus'; @@ -2112,7 +2112,7 @@ export class GraphWebviewProvider implements WebviewProvider { const ref = this.getGraphItemRef(item, 'revision'); if (ref == null) return Promise.resolve(); - return executeCoreCommand(CoreCommands.ShowSCM); + return executeCoreCommand('workbench.view.scm'); } @debug() @@ -2270,7 +2270,7 @@ export class GraphWebviewProvider implements WebviewProvider { return; } - return void executeCoreGitCommand(CoreGitCommands.UndoCommit, ref.repoPath); + return void executeCoreGitCommand('git.undoCommit', ref.repoPath); } @debug() diff --git a/src/system/command.ts b/src/system/command.ts index fc5ab53..a7985f4 100644 --- a/src/system/command.ts +++ b/src/system/command.ts @@ -2,8 +2,8 @@ import type { Command as CoreCommand, Disposable, Uri } from 'vscode'; import { commands } from 'vscode'; import type { Action, ActionContext } from '../api/gitlens'; import type { Command } from '../commands/base'; -import type { CoreGitCommands } from '../constants'; -import { Commands, CoreCommands } from '../constants'; +import type { CoreCommands, CoreGitCommands } from '../constants'; +import { Commands } from '../constants'; import { Container } from '../container'; interface CommandConstructor { @@ -44,6 +44,14 @@ export function executeActionCommand(action: Action, type SupportedCommands = Commands | `gitlens.views.${string}.focus` | `gitlens.views.${string}.resetViewLocation`; +export function createCommand(command: SupportedCommands, title: string, ...args: T): CoreCommand { + return { + command: command, + title: title, + arguments: args, + }; +} + export function executeCommand(command: SupportedCommands): Thenable; export function executeCommand(command: SupportedCommands, arg: T): Thenable; export function executeCommand( @@ -57,6 +65,14 @@ export function executeCommand( return commands.executeCommand(command, ...args); } +export function createCoreCommand(command: CoreCommands, title: string, ...args: T): CoreCommand { + return { + command: command, + title: title, + arguments: args, + }; +} + export function executeCoreCommand(command: CoreCommands, arg: T): Thenable; export function executeCoreCommand( command: CoreCommands, @@ -66,12 +82,24 @@ export function executeCoreCommand( command: CoreCommands, ...args: T ): Thenable { - if (command !== CoreCommands.ExecuteDocumentSymbolProvider) { + if (command != 'setContext' && command !== 'vscode.executeDocumentSymbolProvider') { Container.instance.telemetry.sendEvent('command/core', { command: command }); } return commands.executeCommand(command, ...args); } +export function createCoreGitCommand( + command: CoreGitCommands, + title: string, + ...args: T +): CoreCommand { + return { + command: command, + title: title, + arguments: args, + }; +} + export function executeCoreGitCommand(command: CoreGitCommands): Thenable; export function executeCoreGitCommand(command: CoreGitCommands, arg: T): Thenable; export function executeCoreGitCommand( diff --git a/src/system/utils.ts b/src/system/utils.ts index aa19a73..d779cd8 100644 --- a/src/system/utils.ts +++ b/src/system/utils.ts @@ -1,6 +1,6 @@ import type { ColorTheme, TextDocument, TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; import { version as codeVersion, ColorThemeKind, env, ViewColumn, window, workspace } from 'vscode'; -import { CoreCommands, ImageMimetypes, Schemes } from '../constants'; +import { ImageMimetypes, Schemes } from '../constants'; import { isGitUri } from '../git/gitUri'; import { executeCoreCommand } from './command'; import { configuration } from './configuration'; @@ -54,7 +54,7 @@ export function findOrOpenEditors(uris: Uri[]): void { } for (const uri of normalizedUris.values()) { - void executeCoreCommand(CoreCommands.Open, uri, { background: true, preview: false }); + void executeCoreCommand('vscode.open', uri, { background: true, preview: false }); } } @@ -112,7 +112,7 @@ export async function openEditor( } if (uri.scheme === Schemes.GitLens && ImageMimetypes[extname(uri.fsPath)]) { - await executeCoreCommand(CoreCommands.Open, uri); + await executeCoreCommand('vscode.open', uri); return undefined; } @@ -127,7 +127,7 @@ export async function openEditor( } catch (ex) { const msg: string = ex?.toString() ?? ''; if (msg.includes('File seems to be binary and cannot be opened as text')) { - await executeCoreCommand(CoreCommands.Open, uri); + await executeCoreCommand('vscode.open', uri); return undefined; } @@ -152,7 +152,7 @@ export async function openWalkthrough( // Takes the following params: walkthroughID: string | { category: string, step: string } | undefined, toSide: boolean | undefined void (await executeCoreCommand( - CoreCommands.OpenWalkthrough, + 'workbench.action.openWalkthrough', { category: `${extensionId}#${walkthroughId}`, step: stepId ? `${extensionId}#${walkthroughId}#${stepId}` : undefined, @@ -176,7 +176,7 @@ export function openWorkspace( return void workspace.updateWorkspaceFolders(count, 0, { uri: uri, name: options?.name }); } - return void executeCoreCommand(CoreCommands.OpenFolder, uri, { + return void executeCoreCommand('vscode.openFolder', uri, { forceNewWindow: options?.location === OpenWorkspaceLocation.NewWindow, }); } diff --git a/src/views/nodes/mergeConflictCurrentChangesNode.ts b/src/views/nodes/mergeConflictCurrentChangesNode.ts index 474f118..61b41b9 100644 --- a/src/views/nodes/mergeConflictCurrentChangesNode.ts +++ b/src/views/nodes/mergeConflictCurrentChangesNode.ts @@ -1,13 +1,14 @@ import type { Command } from 'vscode'; import { MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import type { DiffWithCommandArgs } from '../../commands'; -import { Commands, CoreCommands, GlyphChars } from '../../constants'; +import { Commands, GlyphChars } from '../../constants'; import { CommitFormatter } from '../../git/formatters/commitFormatter'; import { GitUri } from '../../git/gitUri'; import type { GitFile } from '../../git/models/file'; import type { GitMergeStatus } from '../../git/models/merge'; import type { GitRebaseStatus } from '../../git/models/rebase'; import { getReferenceLabel } from '../../git/models/reference'; +import { createCommand, createCoreCommand } from '../../system/command'; import { configuration } from '../../system/configuration'; import type { FileHistoryView } from '../fileHistoryView'; import type { LineHistoryView } from '../lineHistoryView'; @@ -70,16 +71,16 @@ export class MergeConflictCurrentChangesNode extends ViewNode(Commands.DiffWith, 'Open Changes', { lhs: { sha: this.status.mergeBase, uri: GitUri.fromFile(this.file, this.status.repoPath, undefined, true), @@ -99,11 +100,6 @@ export class MergeConflictCurrentChangesNode extends ViewNode implem this._description = undefined; } - override getCommand(): Command | undefined { - return { - title: 'Open File', - command: CoreCommands.Open, - arguments: [ - this.view.container.git.getAbsoluteUri(this.file.path, this.repoPath), - { - preserveFocus: true, - preview: true, - }, - ], - }; + override getCommand(): Command { + return createCoreCommand( + 'vscode.open', + 'Open File', + this.view.container.git.getAbsoluteUri(this.file.path, this.repoPath), + { + preserveFocus: true, + preview: true, + }, + ); } } diff --git a/src/views/nodes/mergeConflictIncomingChangesNode.ts b/src/views/nodes/mergeConflictIncomingChangesNode.ts index e226d7e..9df2910 100644 --- a/src/views/nodes/mergeConflictIncomingChangesNode.ts +++ b/src/views/nodes/mergeConflictIncomingChangesNode.ts @@ -1,13 +1,14 @@ import type { Command } from 'vscode'; import { MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import type { DiffWithCommandArgs } from '../../commands'; -import { Commands, CoreCommands, GlyphChars } from '../../constants'; +import { Commands, GlyphChars } from '../../constants'; import { CommitFormatter } from '../../git/formatters/commitFormatter'; import { GitUri } from '../../git/gitUri'; import type { GitFile } from '../../git/models/file'; import type { GitMergeStatus } from '../../git/models/merge'; import type { GitRebaseStatus } from '../../git/models/rebase'; import { getReferenceLabel } from '../../git/models/reference'; +import { createCommand, createCoreCommand } from '../../system/command'; import { configuration } from '../../system/configuration'; import type { FileHistoryView } from '../fileHistoryView'; import type { LineHistoryView } from '../lineHistoryView'; @@ -90,16 +91,14 @@ export class MergeConflictIncomingChangesNode extends ViewNode(Commands.DiffWith, 'Open Changes', { lhs: { sha: this.status.mergeBase, uri: GitUri.fromFile(this.file, this.status.repoPath, undefined, true), @@ -120,11 +119,6 @@ export class MergeConflictIncomingChangesNode extends ViewNode { async openEditor() { const rebaseTodoUri = Uri.joinPath(this.uri, '.git', 'rebase-merge', 'git-rebase-todo'); - await executeCoreCommand(CoreCommands.OpenWith, rebaseTodoUri, 'gitlens.rebase', { + await executeCoreCommand('vscode.openWith', rebaseTodoUri, 'gitlens.rebase', { preview: false, }); } diff --git a/src/views/viewCommands.ts b/src/views/viewCommands.ts index a090474..9d3b6be 100644 --- a/src/views/viewCommands.ts +++ b/src/views/viewCommands.ts @@ -8,7 +8,7 @@ import type { OpenFileAtRevisionCommandArgs, } from '../commands'; import { FileAnnotationType, ViewShowBranchComparison } from '../config'; -import { Commands, ContextKeys, CoreCommands, CoreGitCommands } from '../constants'; +import { Commands, ContextKeys } from '../constants'; import type { Container } from '../container'; import { setContext } from '../context'; import { browseAtRevision } from '../git/actions'; @@ -549,7 +549,7 @@ export class ViewCommands { private openInTerminal(node: RepositoryNode | RepositoryFolderNode) { if (!(node instanceof RepositoryNode) && !(node instanceof RepositoryFolderNode)) return Promise.resolve(); - return executeCoreCommand(CoreCommands.OpenInTerminal, Uri.file(node.repo.path)); + return executeCoreCommand('openInTerminal', Uri.file(node.repo.path)); } @debug() @@ -602,7 +602,7 @@ export class ViewCommands { @debug() private publishRepository(node: BranchNode | BranchTrackingStatusNode) { if (node instanceof BranchNode || node instanceof BranchTrackingStatusNode) { - return executeCoreGitCommand(CoreGitCommands.Publish, Uri.file(node.repoPath)); + return executeCoreGitCommand('git.publish', Uri.file(node.repoPath)); } return Promise.resolve(); } @@ -823,7 +823,7 @@ export class ViewCommands { return; } - await executeCoreGitCommand(CoreGitCommands.UndoCommit, node.repoPath); + await executeCoreGitCommand('git.undoCommit', node.repoPath); } @debug() diff --git a/src/webviews/commitDetails/commitDetailsWebview.ts b/src/webviews/commitDetails/commitDetailsWebview.ts index 1bc686a..6bc6848 100644 --- a/src/webviews/commitDetails/commitDetailsWebview.ts +++ b/src/webviews/commitDetails/commitDetailsWebview.ts @@ -2,7 +2,7 @@ import type { CancellationToken, ConfigurationChangeEvent, TextDocumentShowOptio import { CancellationTokenSource, Disposable, Uri, ViewColumn, window } from 'vscode'; import { serializeAutolink } from '../../annotations/autolinks'; import type { CopyShaToClipboardCommandArgs } from '../../commands'; -import { Commands, ContextKeys, CoreCommands } from '../../constants'; +import { Commands, ContextKeys } from '../../constants'; import type { Container } from '../../container'; import { getContext } from '../../context'; import type { CommitSelectedEvent } from '../../eventBus'; @@ -326,7 +326,7 @@ export class CommitDetailsWebviewProvider implements WebviewProvider { void this.notifyDidChangeData(); } - await executeCoreCommand(CoreCommands.ShowSCM); + await executeCoreCommand('workbench.view.scm'); }), ]; } diff --git a/src/webviews/rebase/rebaseEditor.ts b/src/webviews/rebase/rebaseEditor.ts index f75fe12..6ca6ed7 100644 --- a/src/webviews/rebase/rebaseEditor.ts +++ b/src/webviews/rebase/rebaseEditor.ts @@ -8,7 +8,7 @@ import type { import { ConfigurationTarget, Disposable, Position, Range, Uri, window, workspace, WorkspaceEdit } from 'vscode'; import { getNonce } from '@env/crypto'; import { ShowCommitsInViewCommand } from '../../commands'; -import { ContextKeys, CoreCommands } from '../../constants'; +import { ContextKeys } from '../../constants'; import type { Container } from '../../container'; import { emojify } from '../../emojis'; import type { GitCommit } from '../../git/models/commit'; @@ -320,7 +320,7 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl break; case SearchCommandType.method: - onIpc(SearchCommandType, e, () => executeCoreCommand(CoreCommands.CustomEditorShowFindWidget)); + onIpc(SearchCommandType, e, () => executeCoreCommand('editor.action.webvieweditor.showFind')); break; case StartCommandType.method: @@ -582,7 +582,7 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl void showRebaseSwitchToTextWarningMessage(); // Open the text version of the document - void executeCoreCommand(CoreCommands.Open, context.document.uri, { + void executeCoreCommand('vscode.open', context.document.uri, { override: false, preview: false, });