This commit is contained in:
Sandeep Somavarapu
2018-09-24 12:09:10 +02:00
parent 0edcbadbaf
commit f0fd4a1cab
2 changed files with 21 additions and 6 deletions

View File

@@ -94,6 +94,11 @@ export class ExtHostOutputChannelBackedByFile extends AbstractExtHostOutputChann
this.validate(); this.validate();
this._appender.append(value); this._appender.append(value);
} }
clear(): void {
this._appender.flush();
super.clear();
}
} }
export class ExtHostLogFileOutputChannel extends AbstractExtHostOutputChannel { export class ExtHostLogFileOutputChannel extends AbstractExtHostOutputChannel {

View File

@@ -351,12 +351,13 @@ class FileOutputChannel extends AbstractFileOutputChannel implements OutputChann
} }
loadModel(): TPromise<ITextModel> { loadModel(): TPromise<ITextModel> {
return this.fileService.resolveContent(this.file, { position: this.startOffset, encoding: 'utf8' }) return this.readContent()
.then(content => { .then(content => this.createModel(content));
this.endOffset = this.startOffset + Buffer.from(content.value).byteLength; }
this.etag = content.etag;
return this.createModel(content.value); clear(): void {
}); this.readContent() // Read content from the file before clearing
.then(() => super.clear());
} }
append(message: string): void { append(message: string): void {
@@ -391,6 +392,15 @@ class FileOutputChannel extends AbstractFileOutputChannel implements OutputChann
this.updateInProgress = false; this.updateInProgress = false;
} }
private readContent(): TPromise<string> {
return this.fileService.resolveContent(this.file, { position: this.startOffset, encoding: 'utf8' })
.then(content => {
this.endOffset = this.startOffset + Buffer.from(content.value).byteLength;
this.etag = content.etag;
return content.value;
});
}
private onDidContentChange(size: number): void { private onDidContentChange(size: number): void {
if (!this.updateInProgress) { if (!this.updateInProgress) {
this.updateInProgress = true; this.updateInProgress = true;