Skip to content

Commit

Permalink
env support in terminal api #20446
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Jul 10, 2017
1 parent 5d024c8 commit ee91eeb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4452,6 +4452,11 @@ declare module 'vscode' {
* Args for the custom shell executable, this does not work on Windows (see #8429)
*/
shellArgs?: string[];
/**
* A custom environment for the terminal, if this is not set the environment will be inherited
* from the VS Code process.
*/
env?: { [key: string]: string };
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ export class MainThreadTerminalService extends MainThreadTerminalServiceShape {
this._toDispose = dispose(this._toDispose);
}

public $createTerminal(name?: string, shellPath?: string, shellArgs?: string[], waitOnExit?: boolean): TPromise<number> {
public $createTerminal(name?: string, shellPath?: string, shellArgs?: string[], env?: { [key: string]: string }, waitOnExit?: boolean): TPromise<number> {
const shellLaunchConfig: IShellLaunchConfig = {
name,
executable: shellPath,
args: shellArgs,
waitOnExit,
ignoreConfigurationCwd: true
ignoreConfigurationCwd: true,
env
};
return TPromise.as(this.terminalService.createInstance(shellLaunchConfig).id);
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/node/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export abstract class MainThreadProgressShape {
}

export abstract class MainThreadTerminalServiceShape {
$createTerminal(name?: string, shellPath?: string, shellArgs?: string[], waitOnExit?: boolean): TPromise<number> { throw ni(); }
$createTerminal(name?: string, shellPath?: string, shellArgs?: string[], env?: { [key: string]: string }, waitOnExit?: boolean): TPromise<number> { throw ni(); }
$dispose(terminalId: number): void { throw ni(); }
$hide(terminalId: number): void { throw ni(); }
$sendText(terminalId: number, text: string, addNewLine: boolean): void { throw ni(); }
Expand Down
5 changes: 3 additions & 2 deletions src/vs/workbench/api/node/extHostTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class ExtHostTerminal implements vscode.Terminal {
name?: string,
shellPath?: string,
shellArgs?: string[],
env?: { [key: string]: string },
waitOnExit?: boolean
) {
this._name = name;
Expand All @@ -35,7 +36,7 @@ export class ExtHostTerminal implements vscode.Terminal {
this._pidPromise = new TPromise<number>(c => {
this._pidPromiseComplete = c;
});
this._proxy.$createTerminal(name, shellPath, shellArgs, waitOnExit).then((id) => {
this._proxy.$createTerminal(name, shellPath, shellArgs, env, waitOnExit).then((id) => {
this._id = id;
this._queuedRequests.forEach((r) => {
r.run(this._proxy, this._id);
Expand Down Expand Up @@ -125,7 +126,7 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
}

public createTerminalFromOptions(options: vscode.TerminalOptions): vscode.Terminal {
let terminal = new ExtHostTerminal(this._proxy, options.name, options.shellPath, options.shellArgs/*, options.waitOnExit*/);
let terminal = new ExtHostTerminal(this._proxy, options.name, options.shellPath, options.shellArgs, options.env/*, options.waitOnExit*/);
this._terminals.push(terminal);
return terminal;
}
Expand Down

0 comments on commit ee91eeb

Please sign in to comment.