1
>
/*---------------------------------------------------------------------------------------------
terminalDataBuffering.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { Event } from '../../../base/common/event.js';
7
>
import { IDisposable } from '../../../base/common/lifecycle.js';
8
>
import { isString } from '../../../base/common/types.js';
9
>
import { IProcessDataEvent } from './terminal.js';
10
>
11
>
interface TerminalDataBuffer extends IDisposable {
12
>
data: string[];
13
>
timeoutId: Timeout;
14
>
}
15
>
16
>
export class TerminalDataBufferer implements IDisposable {
17
>
private readonly _terminalBufferMap = new Map<number, TerminalDataBuffer>();
18
>
19
>
constructor(private readonly _callback: (id: number, data: string) => void) {
20
}
22
>
dispose() {
23
for (const buffer of this._terminalBufferMap.values()) {
24
buffer.dispose();
25
}
26
}
28
>
startBuffering(id: number, event: Event<string | IProcessDataEvent>, throttleBy: number = 5): IDisposable {
29
30
const disposable = event((e: string | IProcessDataEvent) => {