Browse Source

Consolidates executeCommand calls

main
Eric Amodio 2 years ago
parent
commit
94e1ae3622
37 changed files with 199 additions and 152 deletions
  1. +6
    -6
      src/codelens/codeLensProvider.ts
  2. +4
    -3
      src/commands/browseRepoAtRevision.ts
  3. +6
    -6
      src/commands/closeUnchangedFiles.ts
  4. +45
    -7
      src/commands/common.ts
  5. +5
    -5
      src/commands/diffWith.ts
  6. +3
    -2
      src/commands/git/coauthors.ts
  7. +2
    -2
      src/commands/git/push.ts
  8. +3
    -3
      src/commands/refreshHover.ts
  9. +6
    -5
      src/commands/setViewsLayout.ts
  10. +2
    -3
      src/commands/showView.ts
  11. +40
    -37
      src/constants.ts
  12. +4
    -4
      src/container.ts
  13. +2
    -2
      src/context.ts
  14. +2
    -2
      src/env/node/git/localGitProvider.ts
  15. +4
    -4
      src/extension.ts
  16. +3
    -3
      src/git/gitProviderService.ts
  17. +9
    -10
      src/git/models/repository.ts
  18. +1
    -1
      src/hovers/hovers.ts
  19. +4
    -4
      src/partners.ts
  20. +1
    -1
      src/quickpicks/commitQuickPickItems.ts
  21. +2
    -1
      src/views/branchesView.ts
  22. +2
    -1
      src/views/commitsView.ts
  23. +2
    -1
      src/views/contributorsView.ts
  24. +2
    -1
      src/views/fileHistoryView.ts
  25. +2
    -1
      src/views/lineHistoryView.ts
  26. +2
    -2
      src/views/nodes/mergeConflictCurrentChangesNode.ts
  27. +2
    -2
      src/views/nodes/mergeConflictFileNode.ts
  28. +2
    -2
      src/views/nodes/mergeConflictIncomingChangesNode.ts
  29. +4
    -13
      src/views/nodes/rebaseStatusNode.ts
  30. +2
    -1
      src/views/remotesView.ts
  31. +2
    -1
      src/views/repositoriesView.ts
  32. +2
    -2
      src/views/searchAndCompareView.ts
  33. +2
    -1
      src/views/stashesView.ts
  34. +2
    -1
      src/views/tagsView.ts
  35. +7
    -3
      src/views/viewBase.ts
  36. +7
    -5
      src/views/viewCommands.ts
  37. +3
    -4
      src/webviews/rebaseEditor.ts

+ 6
- 6
src/codelens/codeLensProvider.ts View File

@ -3,7 +3,6 @@ import {
CodeLens, CodeLens,
CodeLensProvider, CodeLensProvider,
Command, Command,
commands,
DocumentSelector, DocumentSelector,
DocumentSymbol, DocumentSymbol,
Event, Event,
@ -20,6 +19,7 @@ import {
command, command,
Commands, Commands,
DiffWithPreviousCommandArgs, DiffWithPreviousCommandArgs,
executeCoreCommand,
OpenOnRemoteCommandArgs, OpenOnRemoteCommandArgs,
ShowCommitsInViewCommandArgs, ShowCommitsInViewCommandArgs,
ShowQuickCommitCommandArgs, ShowQuickCommitCommandArgs,
@ -35,7 +35,7 @@ import {
configuration, configuration,
FileAnnotationType, FileAnnotationType,
} from '../configuration'; } from '../configuration';
import { BuiltInCommands, Schemes } from '../constants';
import { CoreCommands, Schemes } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import type { GitUri } from '../git/gitUri'; import type { GitUri } from '../git/gitUri';
import { GitBlame, GitBlameLines, GitCommit } from '../git/models'; import { GitBlame, GitBlameLines, GitCommit } from '../git/models';
@ -158,8 +158,8 @@ export class GitCodeLensProvider implements CodeLensProvider {
} else { } else {
[blame, symbols] = await Promise.all([ [blame, symbols] = await Promise.all([
this.container.git.getBlame(gitUri, document), this.container.git.getBlame(gitUri, document),
commands.executeCommand<SymbolInformation[]>(
BuiltInCommands.ExecuteDocumentSymbolProvider,
executeCoreCommand<[Uri], SymbolInformation[]>(
CoreCommands.ExecuteDocumentSymbolProvider,
document.uri, document.uri,
), ),
]); ]);
@ -167,8 +167,8 @@ export class GitCodeLensProvider implements CodeLensProvider {
if (blame == null || blame?.lines.length === 0) return lenses; if (blame == null || blame?.lines.length === 0) return lenses;
} else if (languageScope.scopes.length !== 1 || !languageScope.scopes.includes(CodeLensScopes.Document)) { } else if (languageScope.scopes.length !== 1 || !languageScope.scopes.includes(CodeLensScopes.Document)) {
symbols = await commands.executeCommand<SymbolInformation[]>(
BuiltInCommands.ExecuteDocumentSymbolProvider,
symbols = await executeCoreCommand<[Uri], SymbolInformation[]>(
CoreCommands.ExecuteDocumentSymbolProvider,
document.uri, document.uri,
); );
} }

+ 4
- 3
src/commands/browseRepoAtRevision.ts View File

@ -1,5 +1,5 @@
import { commands, TextEditor, Uri } from 'vscode';
import { BuiltInCommands } from '../constants';
import { TextEditor, Uri } from 'vscode';
import { CoreCommands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import { Logger } from '../logger'; import { Logger } from '../logger';
@ -10,6 +10,7 @@ import {
command, command,
CommandContext, CommandContext,
Commands, Commands,
executeCoreCommand,
getCommandUri, getCommandUri,
openWorkspace, openWorkspace,
OpenWorkspaceLocation, OpenWorkspaceLocation,
@ -75,7 +76,7 @@ export class BrowseRepoAtRevisionCommand extends ActiveEditorCommand {
}); });
if (!args.openInNewWindow) { if (!args.openInNewWindow) {
void commands.executeCommand(BuiltInCommands.FocusFilesExplorer);
void executeCoreCommand(CoreCommands.FocusFilesExplorer);
} }
} catch (ex) { } catch (ex) {
Logger.error(ex, 'BrowseRepoAtRevisionCommand'); Logger.error(ex, 'BrowseRepoAtRevisionCommand');

+ 6
- 6
src/commands/closeUnchangedFiles.ts View File

@ -1,11 +1,11 @@
import { commands, TextEditor, Uri, window } from 'vscode';
import { TextEditor, Uri, window } from 'vscode';
import { TextEditorComparer, UriComparer } from '../comparers'; import { TextEditorComparer, UriComparer } from '../comparers';
import { BuiltInCommands } from '../constants';
import { CoreCommands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages'; import { Messages } from '../messages';
import { debounce } from '../system/function'; import { debounce } from '../system/function';
import { Command, command, Commands, getRepoPathOrPrompt } from './common';
import { Command, command, Commands, executeCoreCommand, getRepoPathOrPrompt } from './common';
export interface CloseUnchangedFilesCommandArgs { export interface CloseUnchangedFilesCommandArgs {
uris?: Uri[]; uris?: Uri[];
@ -38,7 +38,7 @@ export class CloseUnchangedFilesCommand extends Command {
} }
if (args.uris.length === 0) { if (args.uris.length === 0) {
void commands.executeCommand(BuiltInCommands.CloseAllEditors);
void executeCoreCommand(CoreCommands.CloseAllEditors);
return; return;
} }
@ -106,7 +106,7 @@ export class CloseUnchangedFilesCommand extends Command {
private async closeEditor(timeout: number = 500): Promise<TextEditor | undefined> { private async closeEditor(timeout: number = 500): Promise<TextEditor | undefined> {
const editor = window.activeTextEditor; const editor = window.activeTextEditor;
void (await commands.executeCommand(BuiltInCommands.CloseActiveEditor));
void (await executeCoreCommand(CoreCommands.CloseActiveEditor));
if (editor !== window.activeTextEditor) { if (editor !== window.activeTextEditor) {
return window.activeTextEditor; return window.activeTextEditor;
@ -118,7 +118,7 @@ export class CloseUnchangedFilesCommand extends Command {
private async nextEditor(timeout: number = 500): Promise<TextEditor | undefined> { private async nextEditor(timeout: number = 500): Promise<TextEditor | undefined> {
const editor = window.activeTextEditor; const editor = window.activeTextEditor;
void (await commands.executeCommand(BuiltInCommands.NextEditor));
void (await executeCoreCommand(CoreCommands.NextEditor));
if (editor !== window.activeTextEditor) { if (editor !== window.activeTextEditor) {
return window.activeTextEditor; return window.activeTextEditor;

+ 45
- 7
src/commands/common.ts View File

@ -14,7 +14,7 @@ import {
workspace, workspace,
} from 'vscode'; } from 'vscode';
import type { Action, ActionContext } from '../api/gitlens'; import type { Action, ActionContext } from '../api/gitlens';
import { BuiltInCommands, ImageMimetypes, Schemes } from '../constants';
import { CoreCommands, CoreGitCommands, ImageMimetypes, Schemes } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import { import {
@ -183,6 +183,7 @@ export const enum Commands {
ToggleLineBlame = 'gitlens.toggleLineBlame', ToggleLineBlame = 'gitlens.toggleLineBlame',
ToggleReviewMode = 'gitlens.toggleReviewMode', ToggleReviewMode = 'gitlens.toggleReviewMode',
ToggleZenMode = 'gitlens.toggleZenMode', ToggleZenMode = 'gitlens.toggleZenMode',
ViewsCopy = 'gitlens.views.copy',
ViewsOpenDirectoryDiff = 'gitlens.views.openDirectoryDiff', ViewsOpenDirectoryDiff = 'gitlens.views.openDirectoryDiff',
ViewsOpenDirectoryDiffWithWorking = 'gitlens.views.openDirectoryDiffWithWorking', ViewsOpenDirectoryDiffWithWorking = 'gitlens.views.openDirectoryDiffWithWorking',
@ -208,8 +209,45 @@ export function getMarkdownActionCommand(action: Action
}); });
} }
export function executeCommand<T>(command: Commands, args: T) {
return commands.executeCommand(command, args);
type SupportedCommands = Commands | `gitlens.views.${string}.focus` | `gitlens.views.${string}.resetViewLocation`;
export function executeCommand<U = any>(command: SupportedCommands): Thenable<U>;
export function executeCommand<T = unknown, U = any>(command: SupportedCommands, arg: T): Thenable<U>;
export function executeCommand<T extends [...unknown[]] = [], U = any>(
command: SupportedCommands,
...args: T
): Thenable<U>;
export function executeCommand<T extends [...unknown[]] = [], U = any>(
command: SupportedCommands,
...args: T
): Thenable<U> {
return commands.executeCommand<U>(command, args);
}
export function executeCoreCommand<U = any>(command: CoreCommands): Thenable<U>;
export function executeCoreCommand<T = unknown, U = any>(command: CoreCommands, arg: T): Thenable<U>;
export function executeCoreCommand<T extends [...unknown[]] = [], U = any>(
command: CoreCommands,
...args: T
): Thenable<U>;
export function executeCoreCommand<T extends [...unknown[]] = [], U = any>(
command: CoreCommands,
...args: T
): Thenable<U> {
return commands.executeCommand<U>(command, ...args);
}
export function executeCoreGitCommand<U = any>(command: CoreGitCommands): Thenable<U>;
export function executeCoreGitCommand<T = unknown, U = any>(command: CoreGitCommands, arg: T): Thenable<U>;
export function executeCoreGitCommand<T extends [...unknown[]] = [], U = any>(
command: CoreGitCommands,
...args: T
): Thenable<U>;
export function executeCoreGitCommand<T extends [...unknown[]] = [], U = any>(
command: CoreGitCommands,
...args: T
): Thenable<U> {
return commands.executeCommand<U>(command, ...args);
} }
export function executeEditorCommand<T>(command: Commands, uri: Uri | undefined, args: T) { export function executeEditorCommand<T>(command: Commands, uri: Uri | undefined, args: T) {
@ -700,7 +738,7 @@ export function findOrOpenEditors(uris: Uri[]): void {
} }
for (const uri of normalizedUris.values()) { for (const uri of normalizedUris.values()) {
void commands.executeCommand(BuiltInCommands.Open, uri, { background: true, preview: false });
void executeCoreCommand(CoreCommands.Open, uri, { background: true, preview: false });
} }
} }
@ -715,7 +753,7 @@ export async function openEditor(
} }
if (uri.scheme === Schemes.GitLens && ImageMimetypes[extname(uri.fsPath)]) { if (uri.scheme === Schemes.GitLens && ImageMimetypes[extname(uri.fsPath)]) {
await commands.executeCommand(BuiltInCommands.Open, uri);
await executeCoreCommand(CoreCommands.Open, uri);
return undefined; return undefined;
} }
@ -730,7 +768,7 @@ export async function openEditor(
} catch (ex) { } catch (ex) {
const msg: string = ex?.toString() ?? ''; const msg: string = ex?.toString() ?? '';
if (msg.includes('File seems to be binary and cannot be opened as text')) { if (msg.includes('File seems to be binary and cannot be opened as text')) {
await commands.executeCommand(BuiltInCommands.Open, uri);
await executeCoreCommand(CoreCommands.Open, uri);
return undefined; return undefined;
} }
@ -757,7 +795,7 @@ export function openWorkspace(
return void workspace.updateWorkspaceFolders(count, 0, { uri: uri, name: options?.name }); return void workspace.updateWorkspaceFolders(count, 0, { uri: uri, name: options?.name });
} }
return void commands.executeCommand(BuiltInCommands.OpenFolder, uri, {
return void executeCoreCommand(CoreCommands.OpenFolder, uri, {
forceNewWindow: options?.location === OpenWorkspaceLocation.NewWindow, forceNewWindow: options?.location === OpenWorkspaceLocation.NewWindow,
}); });
} }

+ 5
- 5
src/commands/diffWith.ts View File

@ -1,11 +1,11 @@
import { commands, Range, TextDocumentShowOptions, Uri, ViewColumn } from 'vscode';
import { BuiltInCommands, GlyphChars } from '../constants';
import { Range, TextDocumentShowOptions, Uri, ViewColumn } from 'vscode';
import { CoreCommands, GlyphChars } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { GitCommit, GitRevision } from '../git/models'; import { GitCommit, GitRevision } from '../git/models';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages'; import { Messages } from '../messages';
import { basename } from '../system/path'; import { basename } from '../system/path';
import { command, Command, Commands } from './common';
import { command, Command, Commands, executeCoreCommand } from './common';
export interface DiffWithCommandArgsRevision { export interface DiffWithCommandArgsRevision {
sha: string; sha: string;
@ -174,8 +174,8 @@ export class DiffWithCommand extends Command {
args.showOptions.selection = new Range(args.line, 0, args.line, 0); args.showOptions.selection = new Range(args.line, 0, args.line, 0);
} }
void (await commands.executeCommand(
BuiltInCommands.Diff,
void (await executeCoreCommand(
CoreCommands.Diff,
lhs ?? lhs ??
this.container.git.getRevisionUri(GitRevision.deletedOrMissing, args.lhs.uri.fsPath, args.repoPath), this.container.git.getRevisionUri(GitRevision.deletedOrMissing, args.lhs.uri.fsPath, args.repoPath),
rhs ?? rhs ??

+ 3
- 2
src/commands/git/coauthors.ts View File

@ -1,8 +1,9 @@
import { commands } from 'vscode';
import { CoreCommands } from '../../constants';
import { Container } from '../../container'; import { Container } from '../../container';
import { GitContributor, Repository } from '../../git/models'; import { GitContributor, Repository } from '../../git/models';
import { normalizePath } from '../../system/path'; import { normalizePath } from '../../system/path';
import { ViewsWithRepositoryFolders } from '../../views/viewBase'; import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import { executeCoreCommand } from '../common';
import { import {
PartialStepState, PartialStepState,
pickContributorsStep, pickContributorsStep,
@ -90,7 +91,7 @@ export class CoAuthorsGitCommand extends QuickCommand {
} }
repo.inputBox.value = message; repo.inputBox.value = message;
void (await commands.executeCommand('workbench.view.scm'));
void (await executeCoreCommand(CoreCommands.ShowSCM));
} }
protected async *steps(state: PartialStepState<State>): StepGenerator { protected async *steps(state: PartialStepState<State>): StepGenerator {

+ 2
- 2
src/commands/git/push.ts View File

@ -1,5 +1,5 @@
import { configuration } from '../../configuration'; import { configuration } from '../../configuration';
import { BuiltInGitConfiguration, GlyphChars } from '../../constants';
import { CoreGitConfiguration, GlyphChars } from '../../constants';
import { Container } from '../../container'; import { Container } from '../../container';
import { GitBranch, GitBranchReference, GitReference, Repository } from '../../git/models'; import { GitBranch, GitBranchReference, GitReference, Repository } from '../../git/models';
import { Directive, DirectiveQuickPickItem, FlagsQuickPickItem } from '../../quickpicks'; import { Directive, DirectiveQuickPickItem, FlagsQuickPickItem } from '../../quickpicks';
@ -151,7 +151,7 @@ export class PushGitCommand extends QuickCommand {
} }
private async *confirmStep(state: PushStepState, context: Context): AsyncStepResultGenerator<Flags[]> { private async *confirmStep(state: PushStepState, context: Context): AsyncStepResultGenerator<Flags[]> {
const useForceWithLease = configuration.getAny<boolean>(BuiltInGitConfiguration.UseForcePushWithLease) ?? false;
const useForceWithLease = configuration.getAny<boolean>(CoreGitConfiguration.UseForcePushWithLease) ?? false;
let step: QuickPickStep<FlagsQuickPickItem<Flags>>; let step: QuickPickStep<FlagsQuickPickItem<Flags>>;

+ 3
- 3
src/commands/refreshHover.ts View File

@ -1,6 +1,6 @@
import { commands } from 'vscode';
import { CoreCommands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { command, Command, Commands } from './common';
import { command, Command, Commands, executeCoreCommand } from './common';
@command() @command()
export class RefreshHoverCommand extends Command { export class RefreshHoverCommand extends Command {
@ -10,6 +10,6 @@ export class RefreshHoverCommand extends Command {
async execute() { async execute() {
// TODO@eamodio figure out how to really refresh/update a hover // TODO@eamodio figure out how to really refresh/update a hover
await commands.executeCommand('editor.action.showHover');
await executeCoreCommand(CoreCommands.EditorShowHover);
} }
} }

+ 6
- 5
src/commands/setViewsLayout.ts View File

@ -1,7 +1,8 @@
import { commands, window } from 'vscode';
import { window } from 'vscode';
import { viewsConfigKeys } from '../configuration'; import { viewsConfigKeys } from '../configuration';
import { CoreCommands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { command, Command, Commands } from './common';
import { command, Command, Commands, executeCommand, executeCoreCommand } from './common';
enum ViewsLayout { enum ViewsLayout {
GitLens = 'gitlens', GitLens = 'gitlens',
@ -51,7 +52,7 @@ export class SetViewsLayoutCommand extends Command {
// Because of https://github.com/microsoft/vscode/issues/105774, run the command twice which seems to fix things // Because of https://github.com/microsoft/vscode/issues/105774, run the command twice which seems to fix things
let count = 0; let count = 0;
while (count++ < 2) { while (count++ < 2) {
void (await commands.executeCommand('vscode.moveViews', {
void (await executeCoreCommand(CoreCommands.MoveViews, {
viewIds: viewsConfigKeys.map(view => `gitlens.views.${view}`), viewIds: viewsConfigKeys.map(view => `gitlens.views.${view}`),
destinationId: 'workbench.view.extension.gitlens', destinationId: 'workbench.view.extension.gitlens',
})); }));
@ -64,14 +65,14 @@ export class SetViewsLayoutCommand extends Command {
// Because of https://github.com/microsoft/vscode/issues/105774, run the command twice which seems to fix things // Because of https://github.com/microsoft/vscode/issues/105774, run the command twice which seems to fix things
let count = 0; let count = 0;
while (count++ < 2) { while (count++ < 2) {
void (await commands.executeCommand('vscode.moveViews', {
void (await executeCoreCommand(CoreCommands.MoveViews, {
viewIds: viewsConfigKeys.map(view => `gitlens.views.${view}`), viewIds: viewsConfigKeys.map(view => `gitlens.views.${view}`),
destinationId: 'workbench.view.scm', destinationId: 'workbench.view.scm',
})); }));
} }
} catch { } catch {
for (const view of viewsConfigKeys) { for (const view of viewsConfigKeys) {
void (await commands.executeCommand(`gitlens.views.${view}.resetViewLocation`));
void (await executeCommand(`gitlens.views.${view}.resetViewLocation`));
} }
} }

+ 2
- 3
src/commands/showView.ts View File

@ -1,8 +1,7 @@
import { commands } from 'vscode';
import type { Container } from '../container'; import type { Container } from '../container';
import { ContextKeys, setContext } from '../context'; import { ContextKeys, setContext } from '../context';
import { SyncedState } from '../storage'; import { SyncedState } from '../storage';
import { command, Command, CommandContext, Commands } from './common';
import { command, Command, CommandContext, Commands, executeCommand } from './common';
@command() @command()
export class ShowViewCommand extends Command { export class ShowViewCommand extends Command {
@ -51,7 +50,7 @@ export class ShowViewCommand extends Command {
case Commands.ShowWelcomeView: case Commands.ShowWelcomeView:
await setContext(ContextKeys.ViewsWelcomeVisible, true); await setContext(ContextKeys.ViewsWelcomeVisible, true);
void this.container.storage.store(SyncedState.WelcomeViewVisible, true); void this.container.storage.store(SyncedState.WelcomeViewVisible, true);
void (await commands.executeCommand('gitlens.views.welcome.focus'));
void (await executeCommand('gitlens.views.welcome.focus'));
} }
return Promise.resolve(undefined); return Promise.resolve(undefined);

+ 40
- 37
src/constants.ts View File

@ -44,6 +44,46 @@ export const enum Colors {
UnpulledChangesIconColor = 'gitlens.unpulledChangesIconColor', UnpulledChangesIconColor = 'gitlens.unpulledChangesIconColor',
} }
export const enum CoreCommands {
CloseActiveEditor = 'workbench.action.closeActiveEditor',
CloseAllEditors = 'workbench.action.closeAllEditors',
CursorMove = 'cursorMove',
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',
OpenWith = 'vscode.openWith',
NextEditor = 'workbench.action.nextEditor',
PreviewHtml = 'vscode.previewHtml',
RevealLine = 'revealLine',
SetContext = 'setContext',
ShowExplorer = 'workbench.view.explorer',
ShowReferences = 'editor.action.showReferences',
ShowSCM = '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',
}
export const enum CoreGitConfiguration {
AutoRepositoryDetection = 'git.autoRepositoryDetection',
FetchOnPull = 'git.fetchOnPull',
UseForcePushWithLease = 'git.useForcePushWithLease',
}
export const enum GlyphChars { export const enum GlyphChars {
AngleBracketLeftHeavy = '\u2770', AngleBracketLeftHeavy = '\u2770',
AngleBracketRightHeavy = '\u2771', AngleBracketRightHeavy = '\u2771',
@ -103,40 +143,3 @@ export const enum Schemes {
VslsScc = 'vsls-scc', VslsScc = 'vsls-scc',
Virtual = 'vscode-vfs', Virtual = 'vscode-vfs',
} }
export const enum BuiltInCommands {
CloseActiveEditor = 'workbench.action.closeActiveEditor',
CloseAllEditors = 'workbench.action.closeAllEditors',
CursorMove = 'cursorMove',
Diff = 'vscode.diff',
EditorScroll = 'editorScroll',
ExecuteDocumentSymbolProvider = 'vscode.executeDocumentSymbolProvider',
ExecuteCodeLensProvider = 'vscode.executeCodeLensProvider',
FocusFilesExplorer = 'workbench.files.action.focusFilesExplorer',
InstallExtension = 'workbench.extensions.installExtension',
Open = 'vscode.open',
OpenFolder = 'vscode.openFolder',
OpenInTerminal = 'openInTerminal',
OpenWith = 'vscode.openWith',
NextEditor = 'workbench.action.nextEditor',
PreviewHtml = 'vscode.previewHtml',
RevealLine = 'revealLine',
SetContext = 'setContext',
ShowExplorerActivity = 'workbench.view.explorer',
ShowReferences = 'editor.action.showReferences',
}
export const enum BuiltInGitCommands {
Publish = 'git.publish',
Pull = 'git.pull',
PullRebase = 'git.pullRebase',
Push = 'git.push',
PushForce = 'git.pushForce',
UndoCommit = 'git.undoCommit',
}
export const enum BuiltInGitConfiguration {
AutoRepositoryDetection = 'git.autoRepositoryDetection',
FetchOnPull = 'git.fetchOnPull',
UseForcePushWithLease = 'git.useForcePushWithLease',
}

+ 4
- 4
src/container.ts View File

@ -1,4 +1,4 @@
import { commands, ConfigurationChangeEvent, ConfigurationScope, Event, EventEmitter, ExtensionContext } from 'vscode';
import { ConfigurationChangeEvent, ConfigurationScope, Event, EventEmitter, ExtensionContext } from 'vscode';
import { getSupportedGitProviders } from '@env/providers'; import { getSupportedGitProviders } from '@env/providers';
import { Autolinks } from './annotations/autolinks'; import { Autolinks } from './annotations/autolinks';
import { FileAnnotationController } from './annotations/fileAnnotationController'; import { FileAnnotationController } from './annotations/fileAnnotationController';
@ -6,7 +6,7 @@ import { LineAnnotationController } from './annotations/lineAnnotationController
import { ActionRunners } from './api/actionRunners'; import { ActionRunners } from './api/actionRunners';
import { resetAvatarCache } from './avatars'; import { resetAvatarCache } from './avatars';
import { GitCodeLensController } from './codelens/codeLensController'; import { GitCodeLensController } from './codelens/codeLensController';
import { Commands, ToggleFileAnnotationCommandArgs } from './commands';
import { Commands, executeCommand, ToggleFileAnnotationCommandArgs } from './commands';
import { import {
AnnotationsToggleMode, AnnotationsToggleMode,
Config, Config,
@ -465,7 +465,7 @@ export class Container {
if (mode == null) return config; if (mode == null) return config;
if (mode.annotations != null) { if (mode.annotations != null) {
let command: string | undefined;
let command: Commands | undefined;
switch (mode.annotations) { switch (mode.annotations) {
case 'blame': case 'blame':
config.blame.toggleMode = AnnotationsToggleMode.Window; config.blame.toggleMode = AnnotationsToggleMode.Window;
@ -487,7 +487,7 @@ export class Container {
on: true, on: true,
}; };
// Make sure to delay the execution by a bit so that the configuration changes get propegated first // Make sure to delay the execution by a bit so that the configuration changes get propegated first
setTimeout(() => commands.executeCommand(command!, commandArgs), 50);
setTimeout(() => executeCommand(command!, commandArgs), 50);
} }
} }

+ 2
- 2
src/context.ts View File

@ -1,5 +1,5 @@
import { commands } from 'vscode'; import { commands } from 'vscode';
import { BuiltInCommands } from './constants';
import { CoreCommands } from './constants';
export const enum ContextKeys { export const enum ContextKeys {
ActionPrefix = 'gitlens:action:', ActionPrefix = 'gitlens:action:',
@ -38,5 +38,5 @@ export async function setContext(
value: unknown, value: unknown,
): Promise<void> { ): Promise<void> {
// contextStorage.set(key, value); // contextStorage.set(key, value);
void (await commands.executeCommand(BuiltInCommands.SetContext, key, value));
void (await commands.executeCommand(CoreCommands.SetContext, key, value));
} }

+ 2
- 2
src/env/node/git/localGitProvider.ts View File

@ -23,7 +23,7 @@ import type {
GitExtension, GitExtension,
} from '../../../@types/vscode.git'; } from '../../../@types/vscode.git';
import { configuration } from '../../../configuration'; import { configuration } from '../../../configuration';
import { BuiltInGitConfiguration, GlyphChars, Schemes } from '../../../constants';
import { CoreGitConfiguration, GlyphChars, Schemes } from '../../../constants';
import type { Container } from '../../../container'; import type { Container } from '../../../container';
import { StashApplyError, StashApplyErrorReason } from '../../../git/errors'; import { StashApplyError, StashApplyErrorReason } from '../../../git/errors';
import { import {
@ -323,7 +323,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const autoRepositoryDetection = const autoRepositoryDetection =
configuration.getAny<boolean | 'subFolders' | 'openEditors'>( configuration.getAny<boolean | 'subFolders' | 'openEditors'>(
BuiltInGitConfiguration.AutoRepositoryDetection,
CoreGitConfiguration.AutoRepositoryDetection,
) ?? true; ) ?? true;
if (autoRepositoryDetection === false || autoRepositoryDetection === 'openEditors') return []; if (autoRepositoryDetection === false || autoRepositoryDetection === 'openEditors') return [];

+ 4
- 4
src/extension.ts View File

@ -1,4 +1,4 @@
import { version as codeVersion, commands, env, ExtensionContext, extensions, window, workspace } from 'vscode';
import { version as codeVersion, env, ExtensionContext, extensions, window, workspace } from 'vscode';
import { isWeb } from '@env/platform'; import { isWeb } from '@env/platform';
import { Api } from './api/api'; import { Api } from './api/api';
import type { CreatePullRequestActionContext, GitLensApi, OpenPullRequestActionContext } from './api/gitlens'; import type { CreatePullRequestActionContext, GitLensApi, OpenPullRequestActionContext } from './api/gitlens';
@ -122,7 +122,7 @@ export function activate(context: ExtensionContext): Promise
if (cfg.outputLevel !== OutputLevel.Debug) return; if (cfg.outputLevel !== OutputLevel.Debug) return;
if (await Messages.showDebugLoggingWarningMessage()) { if (await Messages.showDebugLoggingWarningMessage()) {
void commands.executeCommand(Commands.DisableDebugLogging);
void executeCommand(Commands.DisableDebugLogging);
} }
}, 60000); }, 60000);
} }
@ -201,7 +201,7 @@ async function showWelcomeOrWhatsNew(container: Container, version: string, prev
if (window.state.focused) { if (window.state.focused) {
await container.storage.delete(GlobalState.PendingWelcomeOnFocus); await container.storage.delete(GlobalState.PendingWelcomeOnFocus);
await commands.executeCommand(Commands.ShowWelcomePage);
await executeCommand(Commands.ShowWelcomePage);
} else { } else {
// Save pending on window getting focus // Save pending on window getting focus
await container.storage.store(GlobalState.PendingWelcomeOnFocus, true); await container.storage.store(GlobalState.PendingWelcomeOnFocus, true);
@ -214,7 +214,7 @@ async function showWelcomeOrWhatsNew(container: Container, version: string, prev
if (container.storage.get(GlobalState.PendingWelcomeOnFocus) === true) { if (container.storage.get(GlobalState.PendingWelcomeOnFocus) === true) {
void container.storage.delete(GlobalState.PendingWelcomeOnFocus); void container.storage.delete(GlobalState.PendingWelcomeOnFocus);
if (container.config.showWelcomeOnInstall) { if (container.config.showWelcomeOnInstall) {
void commands.executeCommand(Commands.ShowWelcomePage);
void executeCommand(Commands.ShowWelcomePage);
} }
} }
}); });

+ 3
- 3
src/git/gitProviderService.ts View File

@ -17,7 +17,7 @@ import {
} from 'vscode'; } from 'vscode';
import { resetAvatarCache } from '../avatars'; import { resetAvatarCache } from '../avatars';
import { configuration } from '../configuration'; import { configuration } from '../configuration';
import { BuiltInGitConfiguration, GlyphChars, Schemes } from '../constants';
import { CoreGitConfiguration, GlyphChars, Schemes } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { ContextKeys, setContext } from '../context'; import { ContextKeys, setContext } from '../context';
import { ProviderNotFoundError } from '../errors'; import { ProviderNotFoundError } from '../errors';
@ -209,7 +209,7 @@ export class GitProviderService implements Disposable {
if (e.added.length) { if (e.added.length) {
const autoRepositoryDetection = const autoRepositoryDetection =
configuration.getAny<boolean | 'subFolders' | 'openEditors'>( configuration.getAny<boolean | 'subFolders' | 'openEditors'>(
BuiltInGitConfiguration.AutoRepositoryDetection,
CoreGitConfiguration.AutoRepositoryDetection,
) ?? true; ) ?? true;
if (autoRepositoryDetection !== false && autoRepositoryDetection !== 'openEditors') { if (autoRepositoryDetection !== false && autoRepositoryDetection !== 'openEditors') {
void this.discoverRepositories(e.added); void this.discoverRepositories(e.added);
@ -398,7 +398,7 @@ export class GitProviderService implements Disposable {
if (workspaceFolders?.length) { if (workspaceFolders?.length) {
const autoRepositoryDetection = const autoRepositoryDetection =
configuration.getAny<boolean | 'subFolders' | 'openEditors'>( configuration.getAny<boolean | 'subFolders' | 'openEditors'>(
BuiltInGitConfiguration.AutoRepositoryDetection,
CoreGitConfiguration.AutoRepositoryDetection,
) ?? true; ) ?? true;
if (autoRepositoryDetection !== false && autoRepositoryDetection !== 'openEditors') { if (autoRepositoryDetection !== false && autoRepositoryDetection !== 'openEditors') {

+ 9
- 10
src/git/models/repository.ts View File

@ -1,5 +1,4 @@
import { import {
commands,
ConfigurationChangeEvent, ConfigurationChangeEvent,
Disposable, Disposable,
Event, Event,
@ -12,9 +11,9 @@ import {
WorkspaceFolder, WorkspaceFolder,
} from 'vscode'; } from 'vscode';
import type { CreatePullRequestActionContext } from '../../api/gitlens'; import type { CreatePullRequestActionContext } from '../../api/gitlens';
import { executeActionCommand } from '../../commands';
import { executeActionCommand, executeCoreGitCommand } from '../../commands';
import { configuration } from '../../configuration'; import { configuration } from '../../configuration';
import { BuiltInGitCommands, BuiltInGitConfiguration, Schemes } from '../../constants';
import { CoreGitCommands, CoreGitConfiguration, Schemes } from '../../constants';
import { Container } from '../../container'; import { Container } from '../../container';
import { Logger } from '../../logger'; import { Logger } from '../../logger';
import { Messages } from '../../messages'; import { Messages } from '../../messages';
@ -643,11 +642,11 @@ export class Repository implements Disposable {
try { try {
const upstream = await this.hasUpstreamBranch(); const upstream = await this.hasUpstreamBranch();
if (upstream) { if (upstream) {
void (await commands.executeCommand(
options.rebase ? BuiltInGitCommands.PullRebase : BuiltInGitCommands.Pull,
void (await executeCoreGitCommand(
options.rebase ? CoreGitCommands.PullRebase : CoreGitCommands.Pull,
this.path, this.path,
)); ));
} else if (configuration.getAny<boolean>(BuiltInGitConfiguration.FetchOnPull, Uri.file(this.path))) {
} else if (configuration.getAny<boolean>(CoreGitConfiguration.FetchOnPull, Uri.file(this.path))) {
void (await this.container.git.fetch(this.path)); void (await this.container.git.fetch(this.path));
} }
@ -738,8 +737,8 @@ export class Repository implements Disposable {
const currentBranch = await this.getBranch(); const currentBranch = await this.getBranch();
if (branch.id === currentBranch?.id) { if (branch.id === currentBranch?.id) {
void (await commands.executeCommand(
options.force ? BuiltInGitCommands.PushForce : BuiltInGitCommands.Push,
void (await executeCoreGitCommand(
options.force ? CoreGitCommands.PushForce : CoreGitCommands.Push,
this.path, this.path,
)); ));
} else { } else {
@ -755,8 +754,8 @@ export class Repository implements Disposable {
await repo?.push(branch.getRemoteName(), `${options.reference.ref}:${branch.getNameWithoutRemote()}`); await repo?.push(branch.getRemoteName(), `${options.reference.ref}:${branch.getNameWithoutRemote()}`);
} else { } else {
void (await commands.executeCommand(
options.force ? BuiltInGitCommands.PushForce : BuiltInGitCommands.Push,
void (await executeCoreGitCommand(
options.force ? CoreGitCommands.PushForce : CoreGitCommands.Push,
this.path, this.path,
)); ));
} }

+ 1
- 1
src/hovers/hovers.ts View File

@ -337,7 +337,7 @@ export namespace Hovers {
// cc, // cc,
// `${GlyphChars.Dot} ${count} issue/pull request queries completed; refreshing...`, // `${GlyphChars.Dot} ${count} issue/pull request queries completed; refreshing...`,
// ); // );
// void commands.executeCommand('editor.action.showHover');
// void executeCoreCommand(CoreCommands.EditorShowHover);
// }); // });
return autolinks; return autolinks;

+ 4
- 4
src/partners.ts View File

@ -1,7 +1,7 @@
import { CancellationTokenSource, commands, Extension, ExtensionContext, extensions, Uri } from 'vscode';
import { CancellationTokenSource, Extension, ExtensionContext, extensions, Uri } from 'vscode';
import type { ActionContext, HoverCommandsActionContext } from './api/gitlens'; import type { ActionContext, HoverCommandsActionContext } from './api/gitlens';
import { Commands, executeCommand, InviteToLiveShareCommandArgs } from './commands';
import { BuiltInCommands } from './constants';
import { Commands, executeCommand, executeCoreCommand, InviteToLiveShareCommandArgs } from './commands';
import { CoreCommands } from './constants';
import { Container } from './container'; import { Container } from './container';
export async function installExtension<T>( export async function installExtension<T>(
@ -33,7 +33,7 @@ export async function installExtension(
}); });
}); });
await commands.executeCommand(BuiltInCommands.InstallExtension, vsix ?? extensionId);
await executeCoreCommand(CoreCommands.InstallExtension, vsix ?? extensionId);
// Wait for extension activation until timeout expires // Wait for extension activation until timeout expires
timer = setTimeout(() => { timer = setTimeout(() => {
timer = undefined; timer = undefined;

+ 1
- 1
src/quickpicks/commitQuickPickItems.ts View File

@ -89,7 +89,7 @@ export class CommitFileQuickPickItem extends CommandQuickPickItem {
// commit: fileCommit, // commit: fileCommit,
// showOptions: options, // showOptions: options,
// }; // };
// void (await commands.executeCommand(Commands.DiffWithPrevious, fileCommit.toGitUri(), commandArgs));
// void (await executeCommand(Commands.DiffWithPrevious, fileCommit.toGitUri(), commandArgs));
} }
} }

+ 2
- 1
src/views/branchesView.ts View File

@ -8,6 +8,7 @@ import {
TreeItemCollapsibleState, TreeItemCollapsibleState,
window, window,
} from 'vscode'; } from 'vscode';
import { Commands, executeCommand } from '../commands';
import { import {
BranchesViewConfig, BranchesViewConfig,
configuration, configuration,
@ -128,7 +129,7 @@ export class BranchesView extends ViewBase
return [ return [
commands.registerCommand( commands.registerCommand(
this.getQualifiedCommand('copy'), this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
() => executeCommand(Commands.ViewsCopy, this.selection),
this, this,
), ),
commands.registerCommand( commands.registerCommand(

+ 2
- 1
src/views/commitsView.ts View File

@ -8,6 +8,7 @@ import {
TreeItemCollapsibleState, TreeItemCollapsibleState,
window, window,
} from 'vscode'; } from 'vscode';
import { Commands, executeCommand } from '../commands';
import { CommitsViewConfig, configuration, ViewFilesLayout, ViewShowBranchComparison } from '../configuration'; import { CommitsViewConfig, configuration, ViewFilesLayout, ViewShowBranchComparison } from '../configuration';
import { GlyphChars } from '../constants'; import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
@ -196,7 +197,7 @@ export class CommitsView extends ViewBase {
return [ return [
commands.registerCommand( commands.registerCommand(
this.getQualifiedCommand('copy'), this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
() => executeCommand(Commands.ViewsCopy, this.selection),
this, this,
), ),
commands.registerCommand( commands.registerCommand(

+ 2
- 1
src/views/contributorsView.ts View File

@ -9,6 +9,7 @@ import {
window, window,
} from 'vscode'; } from 'vscode';
import { Avatars } from '../avatars'; import { Avatars } from '../avatars';
import { Commands, executeCommand } from '../commands';
import { configuration, ContributorsViewConfig, ViewFilesLayout } from '../configuration'; import { configuration, ContributorsViewConfig, ViewFilesLayout } from '../configuration';
import { Container } from '../container'; import { Container } from '../container';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
@ -135,7 +136,7 @@ export class ContributorsView extends ViewBase
return [ return [
commands.registerCommand( commands.registerCommand(
this.getQualifiedCommand('copy'), this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
() => executeCommand(Commands.ViewsCopy, this.selection),
this, this,
), ),
commands.registerCommand( commands.registerCommand(

+ 2
- 1
src/views/fileHistoryView.ts View File

@ -1,4 +1,5 @@
import { commands, ConfigurationChangeEvent, Disposable } from 'vscode'; import { commands, ConfigurationChangeEvent, Disposable } from 'vscode';
import { Commands, executeCommand } from '../commands';
import { configuration, FileHistoryViewConfig } from '../configuration'; import { configuration, FileHistoryViewConfig } from '../configuration';
import { Container } from '../container'; import { Container } from '../container';
import { ContextKeys, setContext } from '../context'; import { ContextKeys, setContext } from '../context';
@ -35,7 +36,7 @@ export class FileHistoryView extends ViewBase
return [ return [
commands.registerCommand( commands.registerCommand(
this.getQualifiedCommand('copy'), this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
() => executeCommand(Commands.ViewsCopy, this.selection),
this, this,
), ),
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this), commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this),

+ 2
- 1
src/views/lineHistoryView.ts View File

@ -1,4 +1,5 @@
import { commands, ConfigurationChangeEvent, Disposable } from 'vscode'; import { commands, ConfigurationChangeEvent, Disposable } from 'vscode';
import { Commands, executeCommand } from '../commands';
import { configuration, LineHistoryViewConfig } from '../configuration'; import { configuration, LineHistoryViewConfig } from '../configuration';
import { Container } from '../container'; import { Container } from '../container';
import { ContextKeys, setContext } from '../context'; import { ContextKeys, setContext } from '../context';
@ -30,7 +31,7 @@ export class LineHistoryView extends ViewBase
return [ return [
commands.registerCommand( commands.registerCommand(
this.getQualifiedCommand('copy'), this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
() => executeCommand(Commands.ViewsCopy, this.selection),
this, this,
), ),
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this), commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this),

+ 2
- 2
src/views/nodes/mergeConflictCurrentChangesNode.ts View File

@ -1,6 +1,6 @@
import { Command, MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import { Command, MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { Commands, DiffWithCommandArgs } from '../../commands'; import { Commands, DiffWithCommandArgs } from '../../commands';
import { BuiltInCommands, GlyphChars } from '../../constants';
import { CoreCommands, GlyphChars } from '../../constants';
import { CommitFormatter } from '../../git/formatters'; import { CommitFormatter } from '../../git/formatters';
import { GitUri } from '../../git/gitUri'; import { GitUri } from '../../git/gitUri';
import { GitFile, GitMergeStatus, GitRebaseStatus, GitReference } from '../../git/models'; import { GitFile, GitMergeStatus, GitRebaseStatus, GitReference } from '../../git/models';
@ -69,7 +69,7 @@ export class MergeConflictCurrentChangesNode extends ViewNode
if (this.status.mergeBase == null) { if (this.status.mergeBase == null) {
return { return {
title: 'Open Revision', title: 'Open Revision',
command: BuiltInCommands.Open,
command: CoreCommands.Open,
arguments: [this.view.container.git.getRevisionUri('HEAD', this.file.path, this.status.repoPath)], arguments: [this.view.container.git.getRevisionUri('HEAD', this.file.path, this.status.repoPath)],
}; };
} }

+ 2
- 2
src/views/nodes/mergeConflictFileNode.ts View File

@ -1,5 +1,5 @@
import { Command, MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode'; import { Command, MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode';
import { BuiltInCommands } from '../../constants';
import { CoreCommands } from '../../constants';
import { StatusFileFormatter } from '../../git/formatters'; import { StatusFileFormatter } from '../../git/formatters';
import { GitUri } from '../../git/gitUri'; import { GitUri } from '../../git/gitUri';
import { GitFile, GitMergeStatus, GitRebaseStatus } from '../../git/models'; import { GitFile, GitMergeStatus, GitRebaseStatus } from '../../git/models';
@ -119,7 +119,7 @@ export class MergeConflictFileNode extends ViewNode implements
override getCommand(): Command | undefined { override getCommand(): Command | undefined {
return { return {
title: 'Open File', title: 'Open File',
command: BuiltInCommands.Open,
command: CoreCommands.Open,
arguments: [ arguments: [
this.view.container.git.getAbsoluteUri(this.file.path, this.repoPath), this.view.container.git.getAbsoluteUri(this.file.path, this.repoPath),
{ {

+ 2
- 2
src/views/nodes/mergeConflictIncomingChangesNode.ts View File

@ -1,6 +1,6 @@
import { Command, MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode'; import { Command, MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { Commands, DiffWithCommandArgs } from '../../commands'; import { Commands, DiffWithCommandArgs } from '../../commands';
import { BuiltInCommands, GlyphChars } from '../../constants';
import { CoreCommands, GlyphChars } from '../../constants';
import { CommitFormatter } from '../../git/formatters'; import { CommitFormatter } from '../../git/formatters';
import { GitUri } from '../../git/gitUri'; import { GitUri } from '../../git/gitUri';
import { GitFile, GitMergeStatus, GitRebaseStatus, GitReference } from '../../git/models'; import { GitFile, GitMergeStatus, GitRebaseStatus, GitReference } from '../../git/models';
@ -81,7 +81,7 @@ export class MergeConflictIncomingChangesNode extends ViewNode
if (this.status.mergeBase == null) { if (this.status.mergeBase == null) {
return { return {
title: 'Open Revision', title: 'Open Revision',
command: BuiltInCommands.Open,
command: CoreCommands.Open,
arguments: [ arguments: [
this.view.container.git.getRevisionUri(this.status.HEAD.ref, this.file.path, this.status.repoPath), this.view.container.git.getRevisionUri(this.status.HEAD.ref, this.file.path, this.status.repoPath),
], ],

+ 4
- 13
src/views/nodes/rebaseStatusNode.ts View File

@ -1,16 +1,7 @@
import {
Command,
commands,
MarkdownString,
ThemeColor,
ThemeIcon,
TreeItem,
TreeItemCollapsibleState,
Uri,
} from 'vscode';
import { Commands, DiffWithPreviousCommandArgs } from '../../commands';
import { Command, MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode';
import { Commands, DiffWithPreviousCommandArgs, executeCoreCommand } from '../../commands';
import { ViewFilesLayout } from '../../configuration'; import { ViewFilesLayout } from '../../configuration';
import { BuiltInCommands } from '../../constants';
import { CoreCommands } from '../../constants';
import { CommitFormatter } from '../../git/formatters'; import { CommitFormatter } from '../../git/formatters';
import { GitUri } from '../../git/gitUri'; import { GitUri } from '../../git/gitUri';
import { GitBranch, GitCommit, GitRebaseStatus, GitReference, GitRevisionReference, GitStatus } from '../../git/models'; import { GitBranch, GitCommit, GitRebaseStatus, GitReference, GitRevisionReference, GitStatus } from '../../git/models';
@ -121,7 +112,7 @@ export class RebaseStatusNode extends ViewNode {
async openEditor() { async openEditor() {
const rebaseTodoUri = Uri.joinPath(this.uri, '.git', 'rebase-merge', 'git-rebase-todo'); const rebaseTodoUri = Uri.joinPath(this.uri, '.git', 'rebase-merge', 'git-rebase-todo');
await commands.executeCommand(BuiltInCommands.OpenWith, rebaseTodoUri, 'gitlens.rebase', {
await executeCoreCommand(CoreCommands.OpenWith, rebaseTodoUri, 'gitlens.rebase', {
preview: false, preview: false,
}); });
} }

+ 2
- 1
src/views/remotesView.ts View File

@ -8,6 +8,7 @@ import {
TreeItemCollapsibleState, TreeItemCollapsibleState,
window, window,
} from 'vscode'; } from 'vscode';
import { Commands, executeCommand } from '../commands';
import { configuration, RemotesViewConfig, ViewBranchesLayout, ViewFilesLayout } from '../configuration'; import { configuration, RemotesViewConfig, ViewBranchesLayout, ViewFilesLayout } from '../configuration';
import { Container } from '../container'; import { Container } from '../container';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
@ -122,7 +123,7 @@ export class RemotesView extends ViewBase {
return [ return [
commands.registerCommand( commands.registerCommand(
this.getQualifiedCommand('copy'), this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
() => executeCommand(Commands.ViewsCopy, this.selection),
this, this,
), ),
commands.registerCommand( commands.registerCommand(

+ 2
- 1
src/views/repositoriesView.ts View File

@ -8,6 +8,7 @@ import {
ProgressLocation, ProgressLocation,
window, window,
} from 'vscode'; } from 'vscode';
import { Commands, executeCommand } from '../commands';
import { import {
configuration, configuration,
RepositoriesViewConfig, RepositoriesViewConfig,
@ -71,7 +72,7 @@ export class RepositoriesView extends ViewBase
return [ return [
commands.registerCommand( commands.registerCommand(
this.getQualifiedCommand('copy'), this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
() => executeCommand(Commands.ViewsCopy, this.selection),
this, this,
), ),
commands.registerCommand( commands.registerCommand(

+ 2
- 2
src/views/searchAndCompareView.ts View File

@ -1,5 +1,5 @@
import { commands, ConfigurationChangeEvent, Disposable, TreeItem, TreeItemCollapsibleState } from 'vscode'; import { commands, ConfigurationChangeEvent, Disposable, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { getRepoPathOrPrompt } from '../commands';
import { Commands, executeCommand, getRepoPathOrPrompt } from '../commands';
import { configuration, SearchAndCompareViewConfig, ViewFilesLayout } from '../configuration'; import { configuration, SearchAndCompareViewConfig, ViewFilesLayout } from '../configuration';
import { Container } from '../container'; import { Container } from '../container';
import { ContextKeys, setContext } from '../context'; import { ContextKeys, setContext } from '../context';
@ -274,7 +274,7 @@ export class SearchAndCompareView extends ViewBase
commands.registerCommand(this.getQualifiedCommand('clear'), () => this.clear(), this), commands.registerCommand(this.getQualifiedCommand('clear'), () => this.clear(), this),
commands.registerCommand( commands.registerCommand(
this.getQualifiedCommand('copy'), this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
() => executeCommand(Commands.ViewsCopy, this.selection),
this, this,
), ),
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this), commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this),

+ 2
- 1
src/views/stashesView.ts View File

@ -8,6 +8,7 @@ import {
TreeItemCollapsibleState, TreeItemCollapsibleState,
window, window,
} from 'vscode'; } from 'vscode';
import { Commands, executeCommand } from '../commands';
import { configuration, StashesViewConfig, ViewFilesLayout } from '../configuration'; import { configuration, StashesViewConfig, ViewFilesLayout } from '../configuration';
import { Container } from '../container'; import { Container } from '../container';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
@ -110,7 +111,7 @@ export class StashesView extends ViewBase {
return [ return [
commands.registerCommand( commands.registerCommand(
this.getQualifiedCommand('copy'), this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
() => executeCommand(Commands.ViewsCopy, this.selection),
this, this,
), ),
commands.registerCommand( commands.registerCommand(

+ 2
- 1
src/views/tagsView.ts View File

@ -8,6 +8,7 @@ import {
TreeItemCollapsibleState, TreeItemCollapsibleState,
window, window,
} from 'vscode'; } from 'vscode';
import { Commands, executeCommand } from '../commands';
import { configuration, TagsViewConfig, ViewBranchesLayout, ViewFilesLayout } from '../configuration'; import { configuration, TagsViewConfig, ViewBranchesLayout, ViewFilesLayout } from '../configuration';
import { Container } from '../container'; import { Container } from '../container';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
@ -110,7 +111,7 @@ export class TagsView extends ViewBase {
return [ return [
commands.registerCommand( commands.registerCommand(
this.getQualifiedCommand('copy'), this.getQualifiedCommand('copy'),
() => commands.executeCommand('gitlens.views.copy', this.selection),
() => executeCommand(Commands.ViewsCopy, this.selection),
this, this,
), ),
commands.registerCommand( commands.registerCommand(

+ 7
- 3
src/views/viewBase.ts View File

@ -1,6 +1,5 @@
import { import {
CancellationToken, CancellationToken,
commands,
ConfigurationChangeEvent, ConfigurationChangeEvent,
Disposable, Disposable,
Event, Event,
@ -14,6 +13,7 @@ import {
TreeViewVisibilityChangeEvent, TreeViewVisibilityChangeEvent,
window, window,
} from 'vscode'; } from 'vscode';
import { executeCommand } from '../commands';
import { import {
BranchesViewConfig, BranchesViewConfig,
CommitsViewConfig, CommitsViewConfig,
@ -103,7 +103,11 @@ export abstract class ViewBase<
private readonly _lastKnownLimits = new Map<string, number | undefined>(); private readonly _lastKnownLimits = new Map<string, number | undefined>();
constructor(public readonly id: string, public readonly name: string, public readonly container: Container) {
constructor(
public readonly id: `gitlens.views.${string}`,
public readonly name: string,
public readonly container: Container,
) {
this.disposables.push(once(container.onReady)(this.onReady, this)); this.disposables.push(once(container.onReady)(this.onReady, this));
if (Logger.isDebugging || this.container.config.debug) { if (Logger.isDebugging || this.container.config.debug) {
@ -505,7 +509,7 @@ export abstract class ViewBase<
@log() @log()
async show(options?: { preserveFocus?: boolean }) { async show(options?: { preserveFocus?: boolean }) {
try { try {
void (await commands.executeCommand(`${this.id}.focus`, options));
void (await executeCommand(`${this.id}.focus`, options));
} catch (ex) { } catch (ex) {
Logger.error(ex); Logger.error(ex);
} }

+ 7
- 5
src/views/viewCommands.ts View File

@ -7,12 +7,14 @@ import {
DiffWithWorkingCommandArgs, DiffWithWorkingCommandArgs,
executeActionCommand, executeActionCommand,
executeCommand, executeCommand,
executeCoreCommand,
executeCoreGitCommand,
executeEditorCommand, executeEditorCommand,
GitActions, GitActions,
OpenFileAtRevisionCommandArgs, OpenFileAtRevisionCommandArgs,
} from '../commands'; } from '../commands';
import { configuration, FileAnnotationType, ViewShowBranchComparison } from '../configuration'; import { configuration, FileAnnotationType, ViewShowBranchComparison } from '../configuration';
import { BuiltInCommands, BuiltInGitCommands } from '../constants';
import { CoreCommands, CoreGitCommands } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { ContextKeys, setContext } from '../context'; import { ContextKeys, setContext } from '../context';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
@ -460,7 +462,7 @@ export class ViewCommands {
private openInTerminal(node: RepositoryNode | RepositoryFolderNode) { private openInTerminal(node: RepositoryNode | RepositoryFolderNode) {
if (!(node instanceof RepositoryNode) && !(node instanceof RepositoryFolderNode)) return Promise.resolve(); if (!(node instanceof RepositoryNode) && !(node instanceof RepositoryFolderNode)) return Promise.resolve();
return commands.executeCommand(BuiltInCommands.OpenInTerminal, Uri.file(node.repo.path));
return executeCoreCommand(CoreCommands.OpenInTerminal, Uri.file(node.repo.path));
} }
@debug() @debug()
@ -481,7 +483,7 @@ export class ViewCommands {
@debug() @debug()
private publishRepository(node: BranchNode | BranchTrackingStatusNode) { private publishRepository(node: BranchNode | BranchTrackingStatusNode) {
if (node instanceof BranchNode || node instanceof BranchTrackingStatusNode) { if (node instanceof BranchNode || node instanceof BranchTrackingStatusNode) {
return commands.executeCommand(BuiltInGitCommands.Publish, Uri.file(node.repoPath));
return executeCoreGitCommand(CoreGitCommands.Publish, Uri.file(node.repoPath));
} }
return Promise.resolve(); return Promise.resolve();
} }
@ -685,7 +687,7 @@ export class ViewCommands {
return; return;
} }
await commands.executeCommand(BuiltInGitCommands.UndoCommit, node.repoPath);
await executeCoreGitCommand(CoreGitCommands.UndoCommit, node.repoPath);
} }
@debug() @debug()
@ -969,7 +971,7 @@ export class ViewCommands {
// }; // };
// const uri = GitUri.fromFile(file, repoPath, ref); // const uri = GitUri.fromFile(file, repoPath, ref);
// await commands.executeCommand(Commands.DiffWithWorking, uri, args);
// await executeCommand(Commands.DiffWithWorking, uri, args);
// } // }
} }

+ 3
- 4
src/webviews/rebaseEditor.ts View File

@ -1,6 +1,5 @@
import { import {
CancellationToken, CancellationToken,
commands,
ConfigurationTarget, ConfigurationTarget,
CustomTextEditorProvider, CustomTextEditorProvider,
Disposable, Disposable,
@ -14,9 +13,9 @@ import {
WorkspaceEdit, WorkspaceEdit,
} from 'vscode'; } from 'vscode';
import { getNonce } from '@env/crypto'; import { getNonce } from '@env/crypto';
import { ShowQuickCommitCommand } from '../commands';
import { executeCoreCommand, ShowQuickCommitCommand } from '../commands';
import { configuration } from '../configuration'; import { configuration } from '../configuration';
import { BuiltInCommands } from '../constants';
import { CoreCommands } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { RepositoryChange, RepositoryChangeComparisonMode } from '../git/models'; import { RepositoryChange, RepositoryChangeComparisonMode } from '../git/models';
import { Logger } from '../logger'; import { Logger } from '../logger';
@ -466,7 +465,7 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
void Messages.showRebaseSwitchToTextWarningMessage(); void Messages.showRebaseSwitchToTextWarningMessage();
// Open the text version of the document // Open the text version of the document
void commands.executeCommand(BuiltInCommands.Open, context.document.uri, {
void executeCoreCommand(CoreCommands.Open, context.document.uri, {
override: false, override: false,
preview: false, preview: false,
}); });

Loading…
Cancel
Save