diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/terminal.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/terminal.test.ts index c0e300439be..13b9666dbfe 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/terminal.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/terminal.test.ts @@ -271,7 +271,7 @@ suite('window namespace tests', () => { }); test('should fire Terminal.onData on write', (done) => { - const reg1 = window.onDidOpenTerminal(term => { + const reg1 = window.onDidOpenTerminal(async term => { equal(terminal, term); reg1.dispose(); const reg2 = terminal.onDidWriteData(data => { @@ -283,11 +283,15 @@ suite('window namespace tests', () => { }); terminal.dispose(); }); + await startPromise; writeEmitter.fire('bar'); }); + let startResolve: () => void; + const startPromise: Promise = new Promise(r => startResolve = r); const writeEmitter = new EventEmitter(); const virtualProcess: TerminalVirtualProcess = { - onDidWrite: writeEmitter.event + onDidWrite: writeEmitter.event, + start: () => startResolve() }; const terminal = window.createTerminal({ name: 'foo', virtualProcess }); }); diff --git a/src/vs/workbench/api/browser/mainThreadTerminalService.ts b/src/vs/workbench/api/browser/mainThreadTerminalService.ts index e00be6872bd..b15a69d24b7 100644 --- a/src/vs/workbench/api/browser/mainThreadTerminalService.ts +++ b/src/vs/workbench/api/browser/mainThreadTerminalService.ts @@ -34,20 +34,13 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape // ITerminalService listeners this._toDispose.add(_terminalService.onInstanceCreated((instance) => { - if (instance.shellLaunchConfig.isVirtualProcess) { - // Fire events for virtual processes immediately as the extension host already knows - // about them + // 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(instance); this._onInstanceDimensionsChanged(instance); - } else { - // 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(instance); - this._onInstanceDimensionsChanged(instance); - }, EXT_HOST_CREATION_DELAY); - } + }, EXT_HOST_CREATION_DELAY); })); this._toDispose.add(_terminalService.onInstanceDisposed(instance => this._onTerminalDisposed(instance))); diff --git a/src/vs/workbench/contrib/terminal/common/terminalService.ts b/src/vs/workbench/contrib/terminal/common/terminalService.ts index 281b93093e9..558be1e44ea 100644 --- a/src/vs/workbench/contrib/terminal/common/terminalService.ts +++ b/src/vs/workbench/contrib/terminal/common/terminalService.ts @@ -145,7 +145,6 @@ export abstract class TerminalService implements ITerminalService { } public requestVirtualProcess(proxy: ITerminalProcessExtHostProxy, cols: number, rows: number): void { - // Don't need to wait on extensions here as this can only be triggered by an extension this._onInstanceRequestVirtualProcess.fire({ proxy, cols, rows }); }