Use TimeoutTimer instead of node timeout

This commit is contained in:
Alex Ross 2021-07-21 11:44:19 +02:00
parent 79156e629f
commit 1ea2c631ee
No known key found for this signature in database
GPG key ID: 89DDDBA66CBA7840

View file

@ -771,8 +771,8 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
let lastEventTime = new Date().getTime(); let lastEventTime = new Date().getTime();
let lineQueue: string[] = []; let lineQueue: string[] = [];
let doneDebouncing = false; let doneDebouncing = false;
// If "enough" time (3 seconds) has passed without more line data, start processing and stop debouncing. // If "enough" time (3 seconds) has passed without more line data, start processing and stop debouncing.
let startProcessingTimeout: NodeJS.Timeout | undefined; let startProcessingTimeout: Async.TimeoutTimer | undefined;
return terminal.onLineData((line) => { return terminal.onLineData((line) => {
if (skipLine) { if (skipLine) {
skipLine = false; skipLine = false;
@ -781,13 +781,13 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
const currentTime = new Date().getTime(); const currentTime = new Date().getTime();
if (!doneDebouncing && ((currentTime - lastEventTime) < 1500)) { if (!doneDebouncing && ((currentTime - lastEventTime) < 1500)) {
if (startProcessingTimeout) { if (startProcessingTimeout) {
clearTimeout(startProcessingTimeout); startProcessingTimeout.dispose();
} }
if (lineQueue.length > 300) { if (lineQueue.length > 300) {
lineQueue = lineQueue.slice(100, lineQueue.length); lineQueue = lineQueue.slice(100, lineQueue.length);
} }
lineQueue.push(line); lineQueue.push(line);
startProcessingTimeout = setTimeout(() => { startProcessingTimeout = new Async.TimeoutTimer(() => {
if (doneDebouncing) { if (doneDebouncing) {
return; return;
} }
@ -797,7 +797,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
} }
lineQueue = []; lineQueue = [];
if (startProcessingTimeout) { if (startProcessingTimeout) {
clearTimeout(startProcessingTimeout); startProcessingTimeout.dispose();
} }
}, 3000); }, 3000);
lastEventTime = new Date().getTime(); lastEventTime = new Date().getTime();
@ -805,7 +805,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
} else if (!doneDebouncing) { } else if (!doneDebouncing) {
doneDebouncing = true; doneDebouncing = true;
if (startProcessingTimeout) { if (startProcessingTimeout) {
clearTimeout(startProcessingTimeout); startProcessingTimeout.dispose();
} }
for (const queuedLine of lineQueue) { for (const queuedLine of lineQueue) {
watchingProblemMatcher.processLine(queuedLine); watchingProblemMatcher.processLine(queuedLine);