diff --git a/src/vs/workbench/api/common/extHostTerminalShellIntegration.ts b/src/vs/workbench/api/common/extHostTerminalShellIntegration.ts index 37a03148780d4..79b306d2a5ad0 100644 --- a/src/vs/workbench/api/common/extHostTerminalShellIntegration.ts +++ b/src/vs/workbench/api/common/extHostTerminalShellIntegration.ts @@ -12,7 +12,7 @@ import { IExtHostRpcService } from './extHostRpcService.js'; import { IExtHostTerminalService } from './extHostTerminalService.js'; import { Emitter, type Event } from '../../../base/common/event.js'; import { URI } from '../../../base/common/uri.js'; -import { AsyncIterableObject, Barrier, type AsyncIterableEmitter } from '../../../base/common/async.js'; +import { AsyncIterableProducer, Barrier, DeferredPromise, type AsyncIterableEmitter } from '../../../base/common/async.js'; export interface IExtHostTerminalShellIntegration extends ExtHostTerminalShellIntegrationShape { readonly _serviceBrand: undefined; @@ -400,7 +400,7 @@ class InternalTerminalShellExecution { private _createDataStream(): AsyncIterable { if (!this._dataStream) { if (this._isEnded) { - return AsyncIterableObject.EMPTY; + return AsyncIterableProducer.EMPTY; } this._dataStream = new ShellExecutionDataStream(); } @@ -432,7 +432,7 @@ class InternalTerminalShellExecution { class ShellExecutionDataStream extends Disposable { private _barrier: Barrier | undefined; - private _iterables: AsyncIterableObject[] = []; + private _completionPromises: DeferredPromise[] = []; private _emitters: AsyncIterableEmitter[] = []; createIterable(): AsyncIterable { @@ -440,11 +440,13 @@ class ShellExecutionDataStream extends Disposable { this._barrier = new Barrier(); } const barrier = this._barrier; - const iterable = new AsyncIterableObject(async emitter => { + const completionPromise = new DeferredPromise(); + this._completionPromises.push(completionPromise); + const iterable = new AsyncIterableProducer(async emitter => { this._emitters.push(emitter); await barrier.wait(); + completionPromise.complete(undefined); }); - this._iterables.push(iterable); return iterable; } @@ -459,7 +461,7 @@ class ShellExecutionDataStream extends Disposable { } async flush(): Promise { - await Promise.all(this._iterables.map(e => e.toPromise())); + await Promise.all(this._completionPromises.map(p => p.p)); } } diff --git a/src/vs/workbench/api/test/common/extHostTerminalShellIntegration.test.ts b/src/vs/workbench/api/test/common/extHostTerminalShellIntegration.test.ts index 23e544f1568f6..7fb813a6f76ba 100644 --- a/src/vs/workbench/api/test/common/extHostTerminalShellIntegration.test.ts +++ b/src/vs/workbench/api/test/common/extHostTerminalShellIntegration.test.ts @@ -64,7 +64,7 @@ suite('InternalTerminalShellIntegration', () => { } async function emitData(data: string): Promise { - // AsyncIterableObjects are initialized in a microtask, this doesn't matter in practice + // AsyncIterableProducers are initialized in a microtask, this doesn't matter in practice // since the events will always come through in different events. await new Promise(r => queueMicrotask(r)); si.emitData(data);