From 5c4c642e0c0ebdd05f4393f57f47f131fbe5616b Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 27 Jan 2022 12:02:08 -0600 Subject: [PATCH 1/2] fix #141463 --- .../contrib/terminal/browser/terminalInstance.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index bb54b7c3dd142..ae9f10e4487d8 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -73,6 +73,8 @@ import { TerminalCapability } from 'vs/workbench/contrib/terminal/common/capabil 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 { IHistoryService } from 'vs/workbench/services/history/common/history'; +import { Schemas } from 'vs/base/common/network'; const enum Constants { /** @@ -350,7 +352,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(); @@ -1305,9 +1308,14 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { if (this._isDisposed) { return; } - - const trusted = await this._trust(); - if (!trusted) { + 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) { + // something strange is going on if cwd is not userHome in an empty workspace this._onProcessExit({ message: nls.localize('workspaceNotTrustedCreateTerminal', "Cannot launch a terminal process in an untrusted workspace") }); } From 46137a65ec2cafbd6d44b218d9b59f60f1ad77e1 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 27 Jan 2022 12:17:30 -0600 Subject: [PATCH 2/2] set slc cwd --- .../workbench/contrib/terminal/browser/terminalInstance.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index ae9f10e4487d8..8102d37691e33 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -1314,8 +1314,10 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { if (!trusted) { this._onProcessExit({ message: nls.localize('workspaceNotTrustedCreateTerminal', "Cannot launch a terminal process in an untrusted workspace") }); } - } else if (this._cwd !== this._userHome) { - // something strange is going on if cwd is not userHome in an empty workspace + } else if (this._userHome && this._cwd !== this._userHome) { + // ensure that the process is launched in userHome for an empty workspace + this._shellLaunchConfig.cwd = this._userHome; + } else if (!this._userHome) { this._onProcessExit({ message: nls.localize('workspaceNotTrustedCreateTerminal', "Cannot launch a terminal process in an untrusted workspace") }); }