Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create process in an empty workspace when cwd is userHome #141660

Merged
merged 2 commits into from
Jan 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -1305,9 +1308,16 @@ 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._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") });
}

Expand Down