Skip to content

Commit 73d3a29

Browse files
authored
Merge pull request microsoft#183678 from microsoft/tyriar/135022
Force new terminal editor action to open in same locked group
2 parents 828118d + 8f5c76f commit 73d3a29

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/vs/workbench/contrib/terminal/browser/terminalActions.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import { FileKind } from 'vs/platform/files/common/files';
5959
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
6060
import { TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
6161
import { killTerminalIcon, newTerminalIcon } from 'vs/workbench/contrib/terminal/browser/terminalIcons';
62+
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
6263

6364
export const switchTerminalActionViewItemSeparator = '\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500';
6465
export const switchTerminalShowTabsTitle = localize('showTerminalTabs', "Show Tabs");
@@ -227,6 +228,21 @@ export function registerTerminalActions() {
227228
}
228229
});
229230

231+
registerTerminalAction({
232+
id: TerminalCommandId.CreateTerminalEditorSameGroup,
233+
title: { value: localize('workbench.action.terminal.createTerminalEditor', "Create New Terminal in Editor Area"), original: 'Create New Terminal in Editor Area' },
234+
f1: false,
235+
run: async (c, accessor, args) => {
236+
// Force the editor into the same editor group if it's locked. This command is only ever
237+
// called when a terminal is the active editor
238+
const editorGroupsService = accessor.get(IEditorGroupsService);
239+
const instance = await c.service.createTerminal({
240+
location: { viewColumn: editorGroupsService.activeGroup.index }
241+
});
242+
instance.focusWhenReady();
243+
}
244+
});
245+
230246
registerTerminalAction({
231247
id: TerminalCommandId.CreateTerminalEditorSide,
232248
title: { value: localize('workbench.action.terminal.createTerminalEditorSide', "Create New Terminal in Editor Area to the Side"), original: 'Create New Terminal in Editor Area to the Side' },

src/vs/workbench/contrib/terminal/browser/terminalMenus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ export function setupTerminalMenus(): void {
785785

786786
MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
787787
command: {
788-
id: TerminalCommandId.CreateTerminalEditor,
788+
id: TerminalCommandId.CreateTerminalEditorSameGroup,
789789
title: terminalStrings.new,
790790
icon: Codicon.plus
791791
},

src/vs/workbench/contrib/terminal/common/terminal.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ export const enum TerminalCommandId {
527527
FocusPreviousPane = 'workbench.action.terminal.focusPreviousPane',
528528
ShowTabs = 'workbench.action.terminal.showTabs',
529529
CreateTerminalEditor = 'workbench.action.createTerminalEditor',
530+
CreateTerminalEditorSameGroup = 'workbench.action.createTerminalEditorSameGroup',
530531
CreateTerminalEditorSide = 'workbench.action.createTerminalEditorSide',
531532
FocusTabs = 'workbench.action.terminal.focusTabs',
532533
FocusNextPane = 'workbench.action.terminal.focusNextPane',

0 commit comments

Comments
 (0)