Skip to content

Commit

Permalink
Use TimeoutTimer instead of node timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
alexr00 committed Jul 21, 2021
1 parent 79156e6 commit 1ea2c63
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,8 +771,8 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
let lastEventTime = new Date().getTime();
let lineQueue: string[] = [];
let doneDebouncing = false;
// If "enough" time (3 seconds) has passed without more line data, start processing and stop debouncing.
let startProcessingTimeout: NodeJS.Timeout | undefined;
// If "enough" time (3 seconds) has passed without more line data, start processing and stop debouncing.
let startProcessingTimeout: Async.TimeoutTimer | undefined;
return terminal.onLineData((line) => {
if (skipLine) {
skipLine = false;
Expand All @@ -781,13 +781,13 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
const currentTime = new Date().getTime();
if (!doneDebouncing && ((currentTime - lastEventTime) < 1500)) {
if (startProcessingTimeout) {
clearTimeout(startProcessingTimeout);
startProcessingTimeout.dispose();
}
if (lineQueue.length > 300) {
lineQueue = lineQueue.slice(100, lineQueue.length);
}
lineQueue.push(line);
startProcessingTimeout = setTimeout(() => {
startProcessingTimeout = new Async.TimeoutTimer(() => {
if (doneDebouncing) {
return;
}
Expand All @@ -797,15 +797,15 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
}
lineQueue = [];
if (startProcessingTimeout) {
clearTimeout(startProcessingTimeout);
startProcessingTimeout.dispose();
}
}, 3000);
lastEventTime = new Date().getTime();
return;
} else if (!doneDebouncing) {
doneDebouncing = true;
if (startProcessingTimeout) {
clearTimeout(startProcessingTimeout);
startProcessingTimeout.dispose();
}
for (const queuedLine of lineQueue) {
watchingProblemMatcher.processLine(queuedLine);
Expand Down

0 comments on commit 1ea2c63

Please sign in to comment.