Skip to content

Commit

Permalink
#42594 Do not flush if there are no contents to flush
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jan 31, 2018
1 parent 648c46d commit c362830
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/vs/workbench/parts/output/electron-browser/outputServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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();
}
Expand All @@ -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 = '';
}
Expand All @@ -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 {
Expand Down

0 comments on commit c362830

Please sign in to comment.