mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
Add createTerminal with options API with new option waitOnExit
Fixes #15583
This commit is contained in:
@@ -277,7 +277,10 @@ export function createApiFactory(initData: IInitData, threadService: IThreadServ
|
||||
createOutputChannel(name: string): vscode.OutputChannel {
|
||||
return extHostOutputService.createOutputChannel(name);
|
||||
},
|
||||
createTerminal(name?: string, shellPath?: string, shellArgs?: string[]): vscode.Terminal {
|
||||
createTerminal(nameOrOptions: vscode.TerminalOptions | string, shellPath?: string, shellArgs?: string[]): vscode.Terminal {
|
||||
if (typeof nameOrOptions === 'object') {
|
||||
return extHostTerminalService.createTerminalFromOptions(<vscode.TerminalOptions>nameOrOptions);
|
||||
}
|
||||
return extHostTerminalService.createTerminal(name, shellPath, shellArgs);
|
||||
},
|
||||
// proposed API
|
||||
|
||||
@@ -184,7 +184,7 @@ export abstract class MainThreadOutputServiceShape {
|
||||
}
|
||||
|
||||
export abstract class MainThreadTerminalServiceShape {
|
||||
$createTerminal(name?: string, shellPath?: string, shellArgs?: string[]): TPromise<number> { throw ni(); }
|
||||
$createTerminal(name?: string, shellPath?: string, shellArgs?: 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(); }
|
||||
|
||||
@@ -20,14 +20,20 @@ export class ExtHostTerminal implements vscode.Terminal {
|
||||
private _pidPromise: TPromise<number>;
|
||||
private _pidPromiseComplete: TValueCallback<number>;
|
||||
|
||||
constructor(proxy: MainThreadTerminalServiceShape, name?: string, shellPath?: string, shellArgs?: string[]) {
|
||||
constructor(
|
||||
proxy: MainThreadTerminalServiceShape,
|
||||
name?: string,
|
||||
shellPath?: string,
|
||||
shellArgs?: string[],
|
||||
waitOnExit?: boolean
|
||||
) {
|
||||
this._name = name;
|
||||
this._queuedRequests = [];
|
||||
this._proxy = proxy;
|
||||
this._pidPromise = new TPromise<number>(c => {
|
||||
this._pidPromiseComplete = c;
|
||||
});
|
||||
this._proxy.$createTerminal(name, shellPath, shellArgs).then((id) => {
|
||||
this._proxy.$createTerminal(name, shellPath, shellArgs, waitOnExit).then((id) => {
|
||||
this._id = id;
|
||||
this._queuedRequests.forEach((r) => {
|
||||
r.run(this._proxy, this._id);
|
||||
@@ -107,6 +113,12 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
|
||||
return terminal;
|
||||
}
|
||||
|
||||
public createTerminalFromOptions(options: vscode.TerminalOptions): vscode.Terminal {
|
||||
let terminal = new ExtHostTerminal(this._proxy, options.name, options.shellPath, options.shellArgs, options.waitOnExit);
|
||||
this._terminals.push(terminal);
|
||||
return terminal;
|
||||
}
|
||||
|
||||
public get onDidCloseTerminal(): Event<vscode.Terminal> {
|
||||
return this._onDidCloseTerminal && this._onDidCloseTerminal.event;
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ export class MainThreadTerminalService extends MainThreadTerminalServiceShape {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
|
||||
public $createTerminal(name?: string, shellPath?: string, shellArgs?: string[]): TPromise<number> {
|
||||
return TPromise.as(this.terminalService.createInstance(name, shellPath, shellArgs, true).id);
|
||||
public $createTerminal(name?: string, shellPath?: string, shellArgs?: string[], waitOnExit?: boolean): TPromise<number> {
|
||||
return TPromise.as(this.terminalService.createInstance(name, shellPath, shellArgs, waitOnExit, true).id);
|
||||
}
|
||||
|
||||
public $show(terminalId: number, preserveFocus: boolean): void {
|
||||
|
||||
Reference in New Issue
Block a user