Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/node/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>;
$dispose(terminalId: number): void;
$hide(terminalId: number): void;
Expand Down Expand Up @@ -904,7 +904,7 @@ export interface ShellLaunchConfigDto {
name?: string;
executable?: string;
args?: string[] | string;
cwd?: string;
cwd?: string | URI;
env?: { [key: string]: string };
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/node/extHostTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/parts/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it on mac and it seems like this is the one we want.

}

let cwd: string | undefined;
Expand Down