Ensure final cell execution update is not delayed

This commit is contained in:
Rob Lourens
2021-08-11 14:52:29 -07:00
parent 8b598d67ed
commit ff681a5db2
2 changed files with 12 additions and 5 deletions

View File

@@ -468,6 +468,10 @@ class NotebookCellExecutionTask extends Disposable {
runEndTime: endTime,
lastRunSuccess: success
});
// The last update needs to be ordered correctly and applied immediately,
// so we use updateSoon and immediately flush.
that._collector.flush();
},
clearOutput(cell?: vscode.NotebookCell): Thenable<void> {
@@ -511,13 +515,17 @@ class TimeoutBasedCollector<T> {
this.batch.push(item);
if (!this.waitPromise) {
this.waitPromise = timeout(this.delay).then(() => {
this.waitPromise = undefined;
const batch = this.batch;
this.batch = [];
return this.callback(batch);
return this.flush();
});
}
return this.waitPromise;
}
flush(): void | Promise<void> {
this.waitPromise = undefined;
const batch = this.batch;
this.batch = [];
return this.callback(batch);
}
}