diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 1fa633997a92c..430c42aca4de6 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -6835,9 +6835,9 @@ declare module 'vscode' { shellArgs?: string[]; /** - * A path for the current working directory to be used for the terminal. + * A path or Uri for the current working directory to be used for the terminal. */ - cwd?: string; + cwd?: string | Uri; /** * Object with environment variables that will be added to the VS Code process. diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 7c71fc1cf5688..4281c255422e6 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -343,7 +343,7 @@ export interface MainThreadProgressShape extends IDisposable { } export interface MainThreadTerminalServiceShape extends IDisposable { - $createTerminal(name?: string, shellPath?: string, shellArgs?: string[], cwd?: string, env?: { [key: string]: string }, waitOnExit?: boolean): Promise<{ id: number, name: string }>; + $createTerminal(name?: string, shellPath?: string, shellArgs?: string[], cwd?: string | URI, env?: { [key: string]: string }, waitOnExit?: boolean): Promise<{ id: number, name: string }>; $createTerminalRenderer(name: string): Promise; $dispose(terminalId: number): void; $hide(terminalId: number): void; @@ -904,7 +904,7 @@ export interface ShellLaunchConfigDto { name?: string; executable?: string; args?: string[] | string; - cwd?: string; + cwd?: string | URI; env?: { [key: string]: string }; } diff --git a/src/vs/workbench/api/node/extHostTerminalService.ts b/src/vs/workbench/api/node/extHostTerminalService.ts index a1e4524223421..cd535a6baeda0 100644 --- a/src/vs/workbench/api/node/extHostTerminalService.ts +++ b/src/vs/workbench/api/node/extHostTerminalService.ts @@ -102,7 +102,7 @@ export class ExtHostTerminal extends BaseExtHostTerminal implements vscode.Termi public create( shellPath?: string, shellArgs?: string[], - cwd?: string, + cwd?: string | URI, env?: { [key: string]: string }, waitOnExit?: boolean ): void { diff --git a/src/vs/workbench/parts/terminal/common/terminal.ts b/src/vs/workbench/parts/terminal/common/terminal.ts index 41114e0c75b1b..82de1acdc4424 100644 --- a/src/vs/workbench/parts/terminal/common/terminal.ts +++ b/src/vs/workbench/parts/terminal/common/terminal.ts @@ -150,7 +150,7 @@ export interface IShellLaunchConfig { * The current working directory of the terminal, this overrides the `terminal.integrated.cwd` * settings key. */ - cwd?: string; + cwd?: string | URI; /** * A custom environment for the terminal, if this is not set the environment will be inherited diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalProcessManager.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalProcessManager.ts index fb18ad12c0ecd..f3ca4f93453ba 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalProcessManager.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalProcessManager.ts @@ -18,7 +18,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; import { IWindowService } from 'vs/platform/windows/common/windows'; import { Schemas } from 'vs/base/common/network'; -import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts'; +import { REMOTE_HOST_SCHEME, getRemoteAuthority } from 'vs/platform/remote/common/remoteHosts'; /** The amount of time to consider terminal errors to be related to the launch */ const LAUNCHING_DURATION = 500; @@ -90,7 +90,17 @@ export class TerminalProcessManager implements ITerminalProcessManager { cols: number, rows: number ): void { - if (this._windowService.getConfiguration().remoteAuthority) { + + let launchRemotely = false; + + if (shellLaunchConfig.cwd && typeof shellLaunchConfig.cwd === 'object') { + launchRemotely = !!getRemoteAuthority(shellLaunchConfig.cwd); + shellLaunchConfig.cwd = shellLaunchConfig.cwd.path; + } else { + launchRemotely = !!this._windowService.getConfiguration().remoteAuthority; + } + + if (launchRemotely) { const activeWorkspaceRootUri = this._historyService.getLastActiveWorkspaceRoot(REMOTE_HOST_SCHEME); this._process = this._instantiationService.createInstance(TerminalProcessExtHostProxy, this._terminalId, shellLaunchConfig, activeWorkspaceRootUri, cols, rows); } else { diff --git a/src/vs/workbench/parts/terminal/node/terminalEnvironment.ts b/src/vs/workbench/parts/terminal/node/terminalEnvironment.ts index 5f8e53e0993d3..c5729bc158e34 100644 --- a/src/vs/workbench/parts/terminal/node/terminalEnvironment.ts +++ b/src/vs/workbench/parts/terminal/node/terminalEnvironment.ts @@ -129,7 +129,7 @@ function _getLangEnvVariable(locale?: string) { export function getCwd(shell: IShellLaunchConfig, root: Uri, customCwd: string): string { if (shell.cwd) { - return shell.cwd; + return (typeof shell.cwd === 'object') ? shell.cwd.path : shell.cwd; } let cwd: string | undefined;