提交 c3c933ad 编写于 作者: D Daniel Imms

Prevent creation of terminals when processes aren't supported

上级 6d22bbd6
...@@ -84,7 +84,7 @@ export class ToggleTerminalAction extends ToggleViewAction { ...@@ -84,7 +84,7 @@ export class ToggleTerminalAction extends ToggleViewAction {
} }
async run() { async run() {
if (this.terminalService.terminalInstances.length === 0) { if (this.terminalService.isProcessSupportRegistered && this.terminalService.terminalInstances.length === 0) {
// If there is not yet an instance attempt to create it here so that we can suggest a // If there is not yet an instance attempt to create it here so that we can suggest a
// new shell on Windows (and not do so when the panel is restored on reload). // new shell on Windows (and not do so when the panel is restored on reload).
const newTerminalInstance = this.terminalService.createTerminal(undefined); const newTerminalInstance = this.terminalService.createTerminal(undefined);
...@@ -201,23 +201,25 @@ export class CreateNewTerminalAction extends Action { ...@@ -201,23 +201,25 @@ export class CreateNewTerminalAction extends Action {
} }
} }
let instance: ITerminalInstance | undefined; if (this._terminalService.isProcessSupportRegistered) {
if (folders.length <= 1) { let instance: ITerminalInstance | undefined;
// Allow terminal service to handle the path when there is only a if (folders.length <= 1) {
// single root // Allow terminal service to handle the path when there is only a
instance = this._terminalService.createTerminal(undefined); // single root
} else { instance = this._terminalService.createTerminal(undefined);
const options: IPickOptions<IQuickPickItem> = { } else {
placeHolder: localize('workbench.action.terminal.newWorkspacePlaceholder', "Select current working directory for new terminal") const options: IPickOptions<IQuickPickItem> = {
}; placeHolder: localize('workbench.action.terminal.newWorkspacePlaceholder', "Select current working directory for new terminal")
const workspace = await this._commandService.executeCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, [options]); };
if (!workspace) { const workspace = await this._commandService.executeCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, [options]);
// Don't create the instance if the workspace picker was canceled if (!workspace) {
return; // Don't create the instance if the workspace picker was canceled
return;
}
instance = this._terminalService.createTerminal({ cwd: workspace.uri });
} }
instance = this._terminalService.createTerminal({ cwd: workspace.uri }); this._terminalService.setActiveInstance(instance);
} }
this._terminalService.setActiveInstance(instance);
await this._terminalService.showPanel(true); await this._terminalService.showPanel(true);
} }
} }
...@@ -442,11 +444,13 @@ export function registerTerminalActions() { ...@@ -442,11 +444,13 @@ export function registerTerminalActions() {
} }
async run(accessor: ServicesAccessor) { async run(accessor: ServicesAccessor) {
const terminalService = accessor.get(ITerminalService); const terminalService = accessor.get(ITerminalService);
const instance = terminalService.createTerminal(undefined); if (terminalService.isProcessSupportRegistered) {
if (!instance) { const instance = terminalService.createTerminal(undefined);
return; if (!instance) {
return;
}
terminalService.setActiveInstance(instance);
} }
terminalService.setActiveInstance(instance);
await terminalService.showPanel(true); await terminalService.showPanel(true);
} }
}); });
...@@ -1183,11 +1187,13 @@ export function registerTerminalActions() { ...@@ -1183,11 +1187,13 @@ export function registerTerminalActions() {
} }
async run(accessor: ServicesAccessor, args?: { cwd?: string }) { async run(accessor: ServicesAccessor, args?: { cwd?: string }) {
const terminalService = accessor.get(ITerminalService); const terminalService = accessor.get(ITerminalService);
const instance = terminalService.createTerminal({ cwd: args?.cwd }); if (terminalService.isProcessSupportRegistered) {
if (!instance) { const instance = terminalService.createTerminal({ cwd: args?.cwd });
return; if (!instance) {
return;
}
terminalService.setActiveInstance(instance);
} }
terminalService.setActiveInstance(instance);
return terminalService.showPanel(true); return terminalService.showPanel(true);
} }
}); });
......
...@@ -607,6 +607,9 @@ export class TerminalService implements ITerminalService { ...@@ -607,6 +607,9 @@ export class TerminalService implements ITerminalService {
} }
public createTerminal(shell: IShellLaunchConfig = {}): ITerminalInstance { public createTerminal(shell: IShellLaunchConfig = {}): ITerminalInstance {
if (!this.isProcessSupportRegistered) {
throw new Error('Could not create terminal when process support is not registered');
}
if (shell.hideFromUser) { if (shell.hideFromUser) {
const instance = this.createInstance(undefined, shell); const instance = this.createInstance(undefined, shell);
this._backgroundedTerminalInstances.push(instance); this._backgroundedTerminalInstances.push(instance);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册