提交 c362830e 编写于 作者: S Sandeep Somavarapu

#42594 Do not flush if there are no contents to flush

上级 648c46de
......@@ -227,6 +227,7 @@ class OutputChannelBackedByFile extends AbstractFileOutputChannel implements Out
private loadingFromFileInProgress: boolean = false;
private resettingDelayer: ThrottledDelayer<void>;
private readonly rotatingFilePath: string;
private hasContentsToFlush: boolean = false;
constructor(
outputChannelIdentifier: IOutputChannelIdentifier,
......@@ -256,7 +257,7 @@ class OutputChannelBackedByFile extends AbstractFileOutputChannel implements Out
if (this.loadingFromFileInProgress) {
this.appendedMessage += message;
} else {
this.outputWriter.critical(message);
this.write(message);
if (this.model) {
this.appendedMessage += message;
if (!this.modelUpdater.isScheduled()) {
......@@ -289,7 +290,7 @@ class OutputChannelBackedByFile extends AbstractFileOutputChannel implements Out
private startLoadingFromFile(): void {
this.loadingFromFileInProgress = true;
this.outputWriter.flush();
this.flush();
if (this.modelUpdater.isScheduled()) {
this.modelUpdater.cancel();
}
......@@ -298,7 +299,7 @@ class OutputChannelBackedByFile extends AbstractFileOutputChannel implements Out
private finishedLoadingFromFile(): void {
if (this.appendedMessage) {
this.outputWriter.critical(this.appendedMessage);
this.write(this.appendedMessage);
this.appendToModel(this.appendedMessage);
this.appendedMessage = '';
}
......@@ -311,6 +312,18 @@ class OutputChannelBackedByFile extends AbstractFileOutputChannel implements Out
this.resettingDelayer.trigger(() => this.resetModel());
}
}
private write(content: string): void {
this.outputWriter.critical(content);
this.hasContentsToFlush = true;
}
private flush(): void {
if (this.hasContentsToFlush) {
this.outputWriter.flush();
this.hasContentsToFlush = false;
}
}
}
class OutputFileListener extends Disposable {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册