Skip to content

Commit

Permalink
Merge pull request #11982 from Microsoft/octref/10917
Browse files Browse the repository at this point in the history
Add shellArgs. Fix #10917
  • Loading branch information
Tyriar authored Sep 13, 2016
2 parents da4a174 + 9da873d commit fec1d6a
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3500,7 +3500,7 @@ declare namespace vscode {
* @param shellPath Optional path to a custom shell executable to be used in the terminal.
* @return A new Terminal.
*/
export function createTerminal(name?: string, shellPath?: string): Terminal;
export function createTerminal(name?: string, shellPath?: string, shellArgs?: string[]): Terminal;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/node/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ export class ExtHostAPIImplementation {
createOutputChannel(name: string): vscode.OutputChannel {
return extHostOutputService.createOutputChannel(name);
},
createTerminal(name?: string, shellPath?: string): vscode.Terminal {
return extHostTerminalService.createTerminal(name, shellPath);
createTerminal(name?: string, shellPath?: string, shellArgs?: string[]): vscode.Terminal {
return extHostTerminalService.createTerminal(name, shellPath, shellArgs);
}
};

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 @@ -153,7 +153,7 @@ export abstract class MainThreadOutputServiceShape {
}

export abstract class MainThreadTerminalServiceShape {
$createTerminal(name?: string, shellPath?: string): number { throw ni(); }
$createTerminal(name?: string, shellPath?: string, shellArgs?: string[]): 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
10 changes: 4 additions & 6 deletions src/vs/workbench/api/node/extHostTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ import {MainContext, MainThreadTerminalServiceShape} from './extHost.protocol';
export class ExtHostTerminal implements vscode.Terminal {

public _name: string;
public _shellPath: string;

private _id: number;
private _proxy: MainThreadTerminalServiceShape;
private _disposed: boolean;

constructor(proxy: MainThreadTerminalServiceShape, id: number, name?: string, shellPath?: string) {
constructor(proxy: MainThreadTerminalServiceShape, id: number, name?: string, shellPath?: string, shellArgs?: string[]) {
this._name = name;
this._shellPath = shellPath;
this._proxy = proxy;
this._id = this._proxy.$createTerminal(name, shellPath);
this._id = this._proxy.$createTerminal(name, shellPath, shellArgs);
}

public get name(): string {
Expand Down Expand Up @@ -66,7 +64,7 @@ export class ExtHostTerminalService {
this._proxy = threadService.get(MainContext.MainThreadTerminalService);
}

public createTerminal(name?: string, shellPath?: string): vscode.Terminal {
return new ExtHostTerminal(this._proxy, -1, name, shellPath);
public createTerminal(name?: string, shellPath?: string, shellArgs?: string[]): vscode.Terminal {
return new ExtHostTerminal(this._proxy, -1, name, shellPath, shellArgs);
}
}
4 changes: 2 additions & 2 deletions src/vs/workbench/api/node/mainThreadTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export class MainThreadTerminalService extends MainThreadTerminalServiceShape {
super();
}

public $createTerminal(name?: string, shellPath?: string): number {
return this.terminalService.createInstance(name, shellPath).id;
public $createTerminal(name?: string, shellPath?: string, shellArgs?: string[]): number {
return this.terminalService.createInstance(name, shellPath, shellArgs).id;
}

public $show(terminalId: number, preserveFocus: boolean): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export interface ITerminalService {
onInstanceTitleChanged: Event<string>;
terminalInstances: ITerminalInstance[];

createInstance(name?: string, shellPath?: string): ITerminalInstance;
createInstance(name?: string, shellPath?: string, shellArgs?: string[]): ITerminalInstance;
getInstanceFromId(terminalId: number): ITerminalInstance;
getInstanceLabels(): string[];
getActiveInstance(): ITerminalInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ export class TerminalInstance implements ITerminalInstance {
private container: HTMLElement,
private workspace: IWorkspace,
name: string,
shellPath: string,
shell: IShell,
@IKeybindingService private keybindingService: IKeybindingService,
@IMessageService private messageService: IMessageService
) {
this._id = TerminalInstance.ID_COUNTER++;
this._onTitleChanged = new Emitter<string>();
this.createProcess(workspace, name, shellPath);
this.createProcess(workspace, name, shell);

if (container) {
this.attachToElement(container);
Expand Down Expand Up @@ -210,9 +210,11 @@ export class TerminalInstance implements ITerminalInstance {
return typeof data === 'string' ? data.replace(TerminalInstance.EOL_REGEX, os.EOL) : data;
}

private createProcess(workspace: IWorkspace, name?: string, shellPath?: string) {
private createProcess(workspace: IWorkspace, name?: string, shell?: IShell) {
let locale = this.configHelper.isSetLocaleVariables() ? platform.locale : undefined;
let shell = shellPath ? { executable: shellPath, args: [] } : this.configHelper.getShell();
if (!shell) {
shell = this.configHelper.getShell();
}
let env = TerminalInstance.createTerminalEnv(process.env, shell, workspace, locale);
this._title = name ? name : '';
this.process = cp.fork('./terminalProcess', [], {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { IPartService } from 'vs/workbench/services/part/common/partService';
import { ITerminalInstance, ITerminalService, KEYBINDING_CONTEXT_TERMINAL_FOCUS, TERMINAL_PANEL_ID } from 'vs/workbench/parts/terminal/electron-browser/terminal';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { TPromise } from 'vs/base/common/winjs.base';
import { TerminalConfigHelper } from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
import { TerminalConfigHelper, IShell } from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
import { TerminalInstance } from 'vs/workbench/parts/terminal/electron-browser/terminalInstance';

export class TerminalService implements ITerminalService {
Expand Down Expand Up @@ -51,15 +51,19 @@ export class TerminalService implements ITerminalService {
this._configHelper = <TerminalConfigHelper>this.instantiationService.createInstance(TerminalConfigHelper, platform.platform);
}

public createInstance(name?: string, shellPath?: string): ITerminalInstance {
public createInstance(name?: string, shellPath?: string, shellArgs?: string[]): ITerminalInstance {
let shell: IShell = {
executable: shellPath,
args: shellArgs
};
let terminalInstance = <TerminalInstance>this.instantiationService.createInstance(TerminalInstance,
this.terminalFocusContextKey,
this.onTerminalInstanceDispose.bind(this),
this._configHelper,
this.terminalContainer,
this.workspaceContextService.getWorkspace(),
name,
shellPath);
shell);
terminalInstance.addDisposable(terminalInstance.onTitleChanged(this._onInstanceTitleChanged.fire, this._onInstanceTitleChanged));
this.terminalInstances.push(terminalInstance);
if (this.terminalInstances.length === 1) {
Expand Down

0 comments on commit fec1d6a

Please sign in to comment.