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

#40196 Read the content since last read by passing position to file service

上级 78f1f553
...@@ -142,7 +142,7 @@ class FileOutputChannel extends Disposable implements OutputChannel { ...@@ -142,7 +142,7 @@ class FileOutputChannel extends Disposable implements OutputChannel {
private onModelAdded(model: IModel): void { private onModelAdded(model: IModel): void {
if (model.uri.fsPath === this.id) { if (model.uri.fsPath === this.id) {
this.endOffset = this.startOffset + model.getValueLength(); this.endOffset = this.startOffset + new Buffer(model.getValueLength()).byteLength;
this.fileHandler.watch(); this.fileHandler.watch();
} }
} }
...@@ -164,17 +164,8 @@ class FileOutputChannel extends Disposable implements OutputChannel { ...@@ -164,17 +164,8 @@ class FileOutputChannel extends Disposable implements OutputChannel {
let model = this.getModel(); let model = this.getModel();
if (model) { if (model) {
this.fileHandler.loadContent(this.endOffset) this.fileHandler.loadContent(this.endOffset)
.then(delta => { .then(content => {
model = this.getModel(); this.appendContent(content);
if (model && delta) {
const lastLine = model.getLineCount();
const lastLineMaxColumn = model.getLineMaxColumn(lastLine);
model.applyEdits([EditOperation.insert(new Position(lastLine, lastLineMaxColumn), delta)]);
this.endOffset = this.endOffset + delta.length;
if (!this.scrollLock) {
(<OutputPanel>this.panelService.getActivePanel()).revealLastLine();
}
}
this.updateInProgress = false; this.updateInProgress = false;
}, () => this.updateInProgress = false); }, () => this.updateInProgress = false);
} else { } else {
...@@ -182,6 +173,19 @@ class FileOutputChannel extends Disposable implements OutputChannel { ...@@ -182,6 +173,19 @@ class FileOutputChannel extends Disposable implements OutputChannel {
} }
} }
private appendContent(content: string): void {
const model = this.getModel();
if (model && content) {
const lastLine = model.getLineCount();
const lastLineMaxColumn = model.getLineMaxColumn(lastLine);
model.applyEdits([EditOperation.insert(new Position(lastLine, lastLineMaxColumn), content)]);
this.endOffset = this.endOffset + new Buffer(content).byteLength;
if (!this.scrollLock) {
(<OutputPanel>this.panelService.getActivePanel()).revealLastLine();
}
}
}
protected getModel(): IModel { protected getModel(): IModel {
const model = this.modelService.getModel(URI.from({ scheme: OUTPUT_SCHEME, path: this.id })); const model = this.modelService.getModel(URI.from({ scheme: OUTPUT_SCHEME, path: this.id }));
return model && !model.isDisposed() ? model : null; return model && !model.isDisposed() ? model : null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册