Skip to content

Commit bb34501

Browse files
committed
Only register openNativeConsole on non-web
Fixes microsoft#95481
1 parent c54a8ce commit bb34501

2 files changed

Lines changed: 35 additions & 44 deletions

File tree

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

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
2525
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
2626
import { optional } from 'vs/platform/instantiation/common/instantiation';
2727
import { IExplorerService } from 'vs/workbench/contrib/files/common/files';
28+
import { isWeb } from 'vs/base/common/platform';
2829

2930

3031
const OPEN_IN_TERMINAL_COMMAND_ID = 'openInTerminal';
@@ -82,58 +83,37 @@ CommandsRegistry.registerCommand({
8283
}
8384
});
8485

85-
const OPEN_NATIVE_CONSOLE_COMMAND_ID = 'workbench.action.terminal.openNativeConsole';
86-
KeybindingsRegistry.registerCommandAndKeybindingRule({
87-
id: OPEN_NATIVE_CONSOLE_COMMAND_ID,
88-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_C,
89-
when: KEYBINDING_CONTEXT_TERMINAL_NOT_FOCUSED,
90-
weight: KeybindingWeight.WorkbenchContrib,
91-
handler: (accessor) => {
92-
const remoteAgentService = accessor.get(IRemoteAgentService);
93-
const historyService = accessor.get(IHistoryService);
94-
95-
// Open integrated terminal in remote workspaces
96-
if (remoteAgentService.getConnection()) {
97-
const integratedTerminalService = accessor.get(IIntegratedTerminalService);
98-
const root = historyService.getLastActiveWorkspaceRoot(Schemas.vscodeRemote);
99-
let cwd: string | undefined;
86+
if (!isWeb) {
87+
const OPEN_NATIVE_CONSOLE_COMMAND_ID = 'workbench.action.terminal.openNativeConsole';
88+
KeybindingsRegistry.registerCommandAndKeybindingRule({
89+
id: OPEN_NATIVE_CONSOLE_COMMAND_ID,
90+
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_C,
91+
when: KEYBINDING_CONTEXT_TERMINAL_NOT_FOCUSED,
92+
weight: KeybindingWeight.WorkbenchContrib,
93+
handler: (accessor) => {
94+
const historyService = accessor.get(IHistoryService);
95+
// Open external terminal in local workspaces
96+
const terminalService = accessor.get(IExternalTerminalService);
97+
const root = historyService.getLastActiveWorkspaceRoot(Schemas.file);
10098
if (root) {
101-
cwd = root.path;
99+
terminalService.openTerminal(root.fsPath);
102100
} else {
103-
const activeFile = historyService.getLastActiveFile(Schemas.vscodeRemote);
101+
// Opens current file's folder, if no folder is open in editor
102+
const activeFile = historyService.getLastActiveFile(Schemas.file);
104103
if (activeFile) {
105-
cwd = paths.dirname(activeFile.path);
104+
terminalService.openTerminal(paths.dirname(activeFile.fsPath));
106105
}
107106
}
108-
if (cwd) {
109-
const instance = integratedTerminalService.createTerminal({ cwd });
110-
integratedTerminalService.setActiveInstance(instance);
111-
integratedTerminalService.showPanel(true);
112-
}
113-
return;
114107
}
108+
});
115109

116-
// Open external terminal in local workspaces
117-
const terminalService = accessor.get(IExternalTerminalService);
118-
const root = historyService.getLastActiveWorkspaceRoot(Schemas.file);
119-
if (root) {
120-
terminalService.openTerminal(root.fsPath);
121-
} else {
122-
// Opens current file's folder, if no folder is open in editor
123-
const activeFile = historyService.getLastActiveFile(Schemas.file);
124-
if (activeFile) {
125-
terminalService.openTerminal(paths.dirname(activeFile.fsPath));
126-
}
110+
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
111+
command: {
112+
id: OPEN_NATIVE_CONSOLE_COMMAND_ID,
113+
title: { value: nls.localize('globalConsoleAction', "Open New External Terminal"), original: 'Open New External Terminal' }
127114
}
128-
}
129-
});
130-
131-
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
132-
command: {
133-
id: OPEN_NATIVE_CONSOLE_COMMAND_ID,
134-
title: { value: nls.localize('globalConsoleAction', "Open New External Terminal"), original: 'Open New External Terminal' }
135-
}
136-
});
115+
});
116+
}
137117

138118
const openConsoleCommand = {
139119
id: OPEN_IN_TERMINAL_COMMAND_ID,

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,17 @@ if (BrowserFeatures.clipboard.readText) {
159159
}
160160
}
161161

162+
if (platform.isWeb) {
163+
// Register standard external terminal keybinding as integrated terminal when in web as the
164+
// external terminal is not available
165+
KeybindingsRegistry.registerKeybindingRule({
166+
id: TERMINAL_COMMAND_ID.NEW,
167+
weight: KeybindingWeight.WorkbenchContrib,
168+
when: undefined,
169+
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_C
170+
});
171+
}
172+
162173
// Delete word left: ctrl+w
163174
registerSendSequenceKeybinding(String.fromCharCode('W'.charCodeAt(0) - 64), {
164175
primary: KeyMod.CtrlCmd | KeyCode.Backspace,

0 commit comments

Comments
 (0)