提交 a020b859 编写于 作者: D Daniel Imms

Merge remote-tracking branch 'origin/master' into tyriar/11275_terminal_refactor

......@@ -3497,9 +3497,10 @@ declare namespace vscode {
* [Terminal.show](#Terminal.show) in order to show the terminal panel.
*
* @param name Optional human-readable string which will be used to represent the terminal in the UI.
* @param shellPath Optional path to a custom shell executable to be used in the terminal.
* @return A new Terminal.
*/
export function createTerminal(name?: string): Terminal;
export function createTerminal(name?: string, shellPath?: string): Terminal;
}
/**
......
......@@ -260,8 +260,8 @@ export class ExtHostAPIImplementation {
createOutputChannel(name: string): vscode.OutputChannel {
return extHostOutputService.createOutputChannel(name);
},
createTerminal(name?: string): vscode.Terminal {
return extHostTerminalService.createTerminal(name);
createTerminal(name?: string, shellPath?: string): vscode.Terminal {
return extHostTerminalService.createTerminal(name, shellPath);
}
};
......
......@@ -153,7 +153,7 @@ export abstract class MainThreadOutputServiceShape {
}
export abstract class MainThreadTerminalServiceShape {
$createTerminal(name?: string): number { throw ni(); }
$createTerminal(name?: string, shellPath?: 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(); }
......
......@@ -11,15 +11,17 @@ 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) {
constructor(proxy: MainThreadTerminalServiceShape, id: number, name?: string, shellPath?: string) {
this._name = name;
this._shellPath = shellPath;
this._proxy = proxy;
this._id = this._proxy.$createTerminal(name);
this._id = this._proxy.$createTerminal(name, shellPath);
}
public get name(): string {
......@@ -64,7 +66,7 @@ export class ExtHostTerminalService {
this._proxy = threadService.get(MainContext.MainThreadTerminalService);
}
public createTerminal(name?: string): vscode.Terminal {
return new ExtHostTerminal(this._proxy, -1, name);
public createTerminal(name?: string, shellPath?: string): vscode.Terminal {
return new ExtHostTerminal(this._proxy, -1, name, shellPath);
}
}
......@@ -19,8 +19,8 @@ export class MainThreadTerminalService extends MainThreadTerminalServiceShape {
super();
}
public $createTerminal(name?: string): number {
return this.terminalService.createInstance(name).id;
public $createTerminal(name?: string, shellPath?: string): number {
return this.terminalService.createInstance(name, shellPath).id;
}
public $show(terminalId: number, preserveFocus: boolean): void {
......
......@@ -103,7 +103,7 @@ export interface ITerminalService {
configHelper: TerminalConfigHelper;
terminalInstances: ITerminalInstance[];
createInstance(name?: string): ITerminalInstance;
createInstance(name?: string, shellPath?: string): ITerminalInstance;
getInstanceFromId(terminalId: number): ITerminalInstance;
getActiveInstance(): ITerminalInstance;
setActiveInstance(terminalInstance: ITerminalInstance): void;
......
......@@ -48,13 +48,15 @@ export class TerminalInstance implements ITerminalInstance {
private onExitCallback: (TerminalInstance) => void,
private configHelper: TerminalConfigHelper,
private container: HTMLElement,
name: string,
shellPath: string,
@IKeybindingService private keybindingService: IKeybindingService,
@IMessageService private messageService: IMessageService,
@ITerminalService private terminalService: ITerminalService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
) {
this._id = TerminalInstance.ID_COUNTER++;
this.createProcess();
this.createProcess(name, shellPath);
if (container) {
console.log('attach to element', container);
......@@ -149,9 +151,10 @@ export class TerminalInstance implements ITerminalInstance {
return typeof data === 'string' ? data.replace(TerminalInstance.EOL_REGEX, os.EOL) : data;
}
private createProcess(name?: string) {
private createProcess(name?: string, shellPath?: string) {
let locale = this.configHelper.isSetLocaleVariables() ? platform.locale : undefined;
let env = this.createTerminalEnv(process.env, this.configHelper.getShell(), this.contextService.getWorkspace(), locale);
let shell = shellPath ? { executable: shellPath, args: [] } : this.configHelper.getShell();
let env = this.createTerminalEnv(process.env, shell, this.contextService.getWorkspace(), locale);
this._title = name ? name : '';
this.process = cp.fork('./terminalProcess', [], {
env: env,
......
......@@ -50,9 +50,9 @@ export class TerminalService implements ITerminalService {
this._configHelper = <TerminalConfigHelper>this.instantiationService.createInstance(TerminalConfigHelper, platform.platform);
}
public createInstance(): ITerminalInstance {
public createInstance(name?: string, shellPath?: string): ITerminalInstance {
let terminalInstance = <TerminalInstance>this.instantiationService.createInstance(TerminalInstance,
this.terminalFocusContextKey, this.onTerminalInstanceDispose.bind(this), this._configHelper, this.terminalContainer);
this.terminalFocusContextKey, this.onTerminalInstanceDispose.bind(this), this._configHelper, name, shellPath, this.terminalContainer);
this.terminalInstances.push(terminalInstance);
if (this.terminalInstances.length === 1) {
// It's the first instance so it should be focused
......@@ -522,4 +522,10 @@ export class TerminalService implements ITerminalService {
// }
// return parts.join('_') + '.UTF-8';
// }
// }
\ No newline at end of file
// }
=======
export interface ITerminalProcessConfiguration {
name: string;
shell: IShell;
}
>>>>>>> origin/master
......@@ -26,7 +26,7 @@ suite('Workbench - TerminalService', () => {
// assert.ok(env1['ok'], 'Parent environment is copied');
// assert.deepStrictEqual(parentEnv1, { ok: true }, 'Parent environment is unchanged');
// assert.equal(env1['PTYPID'], process.pid.toString(), 'PTYPID is equal to the current PID');
// assert.equal(env1['PTYSHELL'], '/bin/foosh', 'PTYSHELL is equal to the requested shell');
// assert.equal(env1['PTYSHELL'], '/bin/foosh', 'PTYSHELL is equal to the provided shell');
// assert.equal(env1['PTYSHELLARG0'], '-bar', 'PTYSHELLARG0 is equal to the first shell argument');
// assert.equal(env1['PTYSHELLARG1'], 'baz', 'PTYSHELLARG1 is equal to the first shell argument');
// assert.ok(!('PTYSHELLARG2' in env1), 'PTYSHELLARG2 is unset');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册