Skip to content

Commit 77e84b6

Browse files
authored
SCM - add distinct commands/menu items to open a repository in the terminal + setting to control which menu item appears (microsoft#186742)
1 parent 80d23c9 commit 77e84b6

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

src/vs/workbench/contrib/externalTerminal/electron-sandbox/externalTerminal.contribution.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,21 @@ export class ExternalTerminalContribution implements IWorkbenchContribution {
112112
description: nls.localize('explorer.openInTerminalKind', "When opening a file from the Explorer in a terminal, determines what kind of terminal will be launched"),
113113
default: 'integrated'
114114
},
115+
'terminal.sourceControlRepositoriesKind': {
116+
type: 'string',
117+
enum: [
118+
'integrated',
119+
'external',
120+
'both'
121+
],
122+
enumDescriptions: [
123+
nls.localize('terminal.sourceControlRepositoriesKind.integrated', "Use VS Code's integrated terminal."),
124+
nls.localize('terminal.sourceControlRepositoriesKind.external', "Use the configured external terminal."),
125+
nls.localize('terminal.sourceControlRepositoriesKind.both', "Use the other two together.")
126+
],
127+
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"),
128+
default: 'integrated'
129+
},
115130
'terminal.external.windowsExec': {
116131
type: 'string',
117132
description: nls.localize('terminal.external.windowsExec', "Customizes which terminal to run on Windows."),

src/vs/workbench/contrib/scm/browser/scm.contribution.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
367367
primary: KeyMod.Alt | KeyCode.UpArrow
368368
});
369369

370-
CommandsRegistry.registerCommand('scm.openInTerminal', async (accessor, provider: ISCMProvider) => {
370+
CommandsRegistry.registerCommand('scm.openInIntegratedTerminal', async (accessor, provider: ISCMProvider) => {
371371
if (!provider || !provider.rootUri) {
372372
return;
373373
}
@@ -376,13 +376,31 @@ CommandsRegistry.registerCommand('scm.openInTerminal', async (accessor, provider
376376
await commandService.executeCommand('openInIntegratedTerminal', provider.rootUri);
377377
});
378378

379+
CommandsRegistry.registerCommand('scm.openInTerminal', async (accessor, provider: ISCMProvider) => {
380+
if (!provider || !provider.rootUri) {
381+
return;
382+
}
383+
384+
const commandService = accessor.get(ICommandService);
385+
await commandService.executeCommand('openInTerminal', provider.rootUri);
386+
});
387+
379388
MenuRegistry.appendMenuItem(MenuId.SCMSourceControl, {
380389
group: '100_end',
381390
command: {
382391
id: 'scm.openInTerminal',
383-
title: localize('open in terminal', "Open In Terminal")
392+
title: localize('open in external terminal', "Open in External Terminal")
393+
},
394+
when: ContextKeyExpr.and(ContextKeyExpr.equals('scmProviderHasRootUri', true), ContextKeyExpr.or(ContextKeyExpr.equals('config.terminal.sourceControlRepositoriesKind', 'external'), ContextKeyExpr.equals('config.terminal.sourceControlRepositoriesKind', 'both')))
395+
});
396+
397+
MenuRegistry.appendMenuItem(MenuId.SCMSourceControl, {
398+
group: '100_end',
399+
command: {
400+
id: 'scm.openInIntegratedTerminal',
401+
title: localize('open in integrated terminal', "Open in Integrated Terminal")
384402
},
385-
when: ContextKeyExpr.equals('scmProviderHasRootUri', true)
403+
when: ContextKeyExpr.and(ContextKeyExpr.equals('scmProviderHasRootUri', true), ContextKeyExpr.or(ContextKeyExpr.equals('config.terminal.sourceControlRepositoriesKind', 'integrated'), ContextKeyExpr.equals('config.terminal.sourceControlRepositoriesKind', 'both')))
386404
});
387405

388406
registerSingleton(ISCMService, SCMService, InstantiationType.Delayed);

0 commit comments

Comments
 (0)