diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 49afe6fc0eca5..2abf875ffb745 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -74,6 +74,8 @@ import { ITextModel } from 'vs/editor/common/model'; import { IModelService } from 'vs/editor/common/services/model'; import { ITextModelContentProvider, ITextModelService } from 'vs/editor/common/services/resolverService'; import { IDialogService, IConfirmationResult } from 'vs/platform/dialogs/common/dialogs'; +import { IHistoryService } from 'vs/workbench/services/history/common/history'; +import { Schemas } from 'vs/base/common/network'; const enum Constants { /** @@ -351,7 +353,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { @IWorkbenchEnvironmentService workbenchEnvironmentService: IWorkbenchEnvironmentService, @IWorkspaceContextService private readonly _workspaceContextService: IWorkspaceContextService, @IEditorService private readonly _editorService: IEditorService, - @IWorkspaceTrustRequestService private readonly _workspaceTrustRequestService: IWorkspaceTrustRequestService + @IWorkspaceTrustRequestService private readonly _workspaceTrustRequestService: IWorkspaceTrustRequestService, + @IHistoryService private readonly _historyService: IHistoryService ) { super(); @@ -1357,10 +1360,17 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { if (this._isDisposed) { return; } - - const trusted = await this._trust(); - if (!trusted) { - this._onProcessExit({ message: nls.localize('workspaceNotTrustedCreateTerminal', "Cannot launch a terminal process in an untrusted workspace") }); + const activeWorkspaceRootUri = this._historyService.getLastActiveWorkspaceRoot(Schemas.file); + if (activeWorkspaceRootUri) { + const trusted = await this._trust(); + if (!trusted) { + this._onProcessExit({ message: nls.localize('workspaceNotTrustedCreateTerminal', "Cannot launch a terminal process in an untrusted workspace") }); + } + } else if (this._cwd && this._userHome && this._cwd !== this._userHome) { + // something strange is going on if cwd is not userHome in an empty workspace + this._onProcessExit({ + message: nls.localize('workspaceNotTrustedCreateTerminalCwd', "Cannot launch a terminal process in an untrusted workspace with cwd {0} and userHome {1}", this._cwd, this._userHome) + }); } // Re-evaluate dimensions if the container has been set since the xterm instance was created