diff --git a/src/vs/workbench/api/electron-browser/mainThreadTerminalService.ts b/src/vs/workbench/api/electron-browser/mainThreadTerminalService.ts index 51cd24cb54c687ce0cd50efbfdbbb385fd3bb985..e5ad89600954e44a30325e49795c85115cb60f6a 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadTerminalService.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadTerminalService.ts @@ -23,13 +23,19 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostTerminalService); this._toDispose = []; this._toDispose.push(terminalService.onInstanceCreated((terminalInstance) => { - // Delay this message so the TerminalInstance constructor has a change to finish and + // Delay this message so the TerminalInstance constructor has a chance to finish and // return the ID normally to the extension host. The ID that is passed here will be used // to register non-extension API terminals in the extension host. setTimeout(() => this._onTerminalOpened(terminalInstance), 100); })); this._toDispose.push(terminalService.onInstanceDisposed((terminalInstance) => this._onTerminalDisposed(terminalInstance))); this._toDispose.push(terminalService.onInstanceProcessIdReady((terminalInstance) => this._onTerminalProcessIdReady(terminalInstance))); + + // Set initial ext host state + this.terminalService.terminalInstances.forEach(t => { + this._onTerminalOpened(t); + t.processReady.then(() => this._onTerminalProcessIdReady(t)); + }); } public dispose(): void { diff --git a/src/vs/workbench/parts/terminal/common/terminal.ts b/src/vs/workbench/parts/terminal/common/terminal.ts index 2fcfe1c89b77ff65149a7608620a9d3115578000..079e4ac86d7a35bd2b1d0aac2537a059edf18f75 100644 --- a/src/vs/workbench/parts/terminal/common/terminal.ts +++ b/src/vs/workbench/parts/terminal/common/terminal.ts @@ -235,6 +235,8 @@ export interface ITerminalInstance { onProcessIdReady: Event; + processReady: TPromise; + /** * The title of the terminal. This is either title or the process currently running or an * explicit name given to the terminal instance through the extension API. diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index a7f25db2960043c6d82911a5bef57727a178f834..2333fd8b76ec053cf68f7ef2f69fdd26001196b7 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -107,7 +107,9 @@ export class TerminalInstance implements ITerminalInstance { public disableLayout: boolean; public get id(): number { return this._id; } + // TODO: Ideally processId would be merged into processReady public get processId(): number { return this._processId; } + public get processReady(): TPromise { return this._processReady; } public get onDisposed(): Event { return this._onDisposed.event; } public get onFocused(): Event { return this._onFocused.event; } public get onProcessIdReady(): Event { return this._onProcessIdReady.event; }