Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCM - add distinct commands/menu items to open a repository in the terminal + setting to control which menu item appears #186742

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ export class ExternalTerminalContribution implements IWorkbenchContribution {
description: nls.localize('explorer.openInTerminalKind', "When opening a file from the Explorer in a terminal, determines what kind of terminal will be launched"),
default: 'integrated'
},
'terminal.sourceControlRepositoriesKind': {
type: 'string',
enum: [
'integrated',
'external',
'both'
],
enumDescriptions: [
nls.localize('terminal.sourceControlRepositoriesKind.integrated', "Use VS Code's integrated terminal."),
nls.localize('terminal.sourceControlRepositoriesKind.external', "Use the configured external terminal."),
nls.localize('terminal.sourceControlRepositoriesKind.both', "Use the other two together.")
],
description: nls.localize('sourceControlRepositories.openInTerminalKind', "When opening a repository from the Source Control Repositories view in a terminal, determines what kind of terminal will be launched"),
default: 'integrated'
},
'terminal.external.windowsExec': {
type: 'string',
description: nls.localize('terminal.external.windowsExec', "Customizes which terminal to run on Windows."),
Expand Down
24 changes: 21 additions & 3 deletions src/vs/workbench/contrib/scm/browser/scm.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
primary: KeyMod.Alt | KeyCode.UpArrow
});

CommandsRegistry.registerCommand('scm.openInTerminal', async (accessor, provider: ISCMProvider) => {
CommandsRegistry.registerCommand('scm.openInIntegratedTerminal', async (accessor, provider: ISCMProvider) => {
if (!provider || !provider.rootUri) {
return;
}
Expand All @@ -376,13 +376,31 @@ CommandsRegistry.registerCommand('scm.openInTerminal', async (accessor, provider
await commandService.executeCommand('openInIntegratedTerminal', provider.rootUri);
});

CommandsRegistry.registerCommand('scm.openInTerminal', async (accessor, provider: ISCMProvider) => {
if (!provider || !provider.rootUri) {
return;
}

const commandService = accessor.get(ICommandService);
await commandService.executeCommand('openInTerminal', provider.rootUri);
});

MenuRegistry.appendMenuItem(MenuId.SCMSourceControl, {
group: '100_end',
command: {
id: 'scm.openInTerminal',
title: localize('open in terminal', "Open In Terminal")
title: localize('open in external terminal', "Open in External Terminal")
},
when: ContextKeyExpr.and(ContextKeyExpr.equals('scmProviderHasRootUri', true), ContextKeyExpr.or(ContextKeyExpr.equals('config.terminal.sourceControlRepositoriesKind', 'external'), ContextKeyExpr.equals('config.terminal.sourceControlRepositoriesKind', 'both')))
});

MenuRegistry.appendMenuItem(MenuId.SCMSourceControl, {
group: '100_end',
command: {
id: 'scm.openInIntegratedTerminal',
title: localize('open in integrated terminal', "Open in Integrated Terminal")
},
when: ContextKeyExpr.equals('scmProviderHasRootUri', true)
when: ContextKeyExpr.and(ContextKeyExpr.equals('scmProviderHasRootUri', true), ContextKeyExpr.or(ContextKeyExpr.equals('config.terminal.sourceControlRepositoriesKind', 'integrated'), ContextKeyExpr.equals('config.terminal.sourceControlRepositoriesKind', 'both')))
});

registerSingleton(ISCMService, SCMService, InstantiationType.Delayed);
Expand Down