Skip to content

Commit cca8bbb

Browse files
committed
Make SimpleDebounce disposable
1 parent 86141c3 commit cca8bbb

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/common/utils/debounce.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1-
export interface SimpleDebounce {
1+
import { Disposable } from 'vscode';
2+
export interface SimpleDebounce extends Disposable {
23
trigger(): void;
34
}
45

5-
class SimpleDebounceImpl {
6+
class SimpleDebounceImpl implements SimpleDebounce {
67
private timeout: NodeJS.Timeout | undefined;
78

89
constructor(private readonly ms: number, private readonly callback: () => void) {}
910

10-
public trigger() {
11+
public trigger(): void {
1112
if (this.timeout) {
1213
clearTimeout(this.timeout);
1314
}
1415
this.timeout = setTimeout(() => {
1516
this.callback();
1617
}, this.ms);
1718
}
19+
20+
public dispose(): void {
21+
if (this.timeout) {
22+
clearTimeout(this.timeout);
23+
this.timeout = undefined;
24+
}
25+
}
1826
}
1927

2028
export function createSimpleDebounce(ms: number, callback: () => void): SimpleDebounce {

src/features/terminal/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export async function waitForShellIntegration(terminal: Terminal): Promise<boole
5757
resolve(false);
5858
}
5959
});
60+
disposables.push(debounced);
6061
disposables.push(
6162
onDidWriteTerminalData((e) => {
6263
if (e.terminal === terminal) {

0 commit comments

Comments
 (0)