- Do not send replace content from ext host

- implement replaceAll in the model
- cancel all model update operations on replace request
- queue append operation after replace
- clean ups
This commit is contained in:
Sandeep Somavarapu
2021-11-06 13:46:18 +01:00
parent e034d59a8e
commit 3afa5c6420
4 changed files with 186 additions and 229 deletions

View File

@@ -12,7 +12,6 @@ import { Promises, SymlinkSupport } from 'vs/base/node/pfs';
import { AbstractExtHostOutputChannel, ExtHostPushOutputChannel, ExtHostOutputService, LazyOutputChannel } from 'vs/workbench/api/common/extHostOutput';
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { MutableDisposable } from 'vs/base/common/lifecycle';
import { ILogService } from 'vs/platform/log/common/log';
import { createRotatingLogger } from 'vs/platform/log/node/spdlogLog';
import { Logger } from 'spdlog';
@@ -52,18 +51,17 @@ class ExtHostOutputChannelBackedByFile extends AbstractExtHostOutputChannel {
override append(value: string): void {
super.append(value);
this._appender.append(value);
this._onDidAppend.fire();
if (this.visible) {
this.update();
}
}
override replaceAll(value: string): void {
super.replaceAll(value, true);
this._appender.append(value);
this._appender.flush();
super.replaceAll(value);
}
override update(): void {
this._appender.flush();
super.update();
if (this.visible) {
this._appender.flush();
}
}
override show(columnOrPreserveFocus?: vscode.ViewColumn | boolean, preserveFocus?: boolean): void {
@@ -75,6 +73,11 @@ class ExtHostOutputChannelBackedByFile extends AbstractExtHostOutputChannel {
this._appender.flush();
super.clear();
}
private update(): void {
this._appender.flush();
this._id.then(id => this._proxy.$update(id));
}
}
export class ExtHostOutputService2 extends ExtHostOutputService {
@@ -82,7 +85,8 @@ export class ExtHostOutputService2 extends ExtHostOutputService {
private _logsLocation: URI;
private _namePool: number = 1;
private readonly _channels: Map<string, AbstractExtHostOutputChannel> = new Map<string, AbstractExtHostOutputChannel>();
private readonly _visibleChannelDisposable = new MutableDisposable();
private visibleChannelId: string | null = null;
constructor(
@IExtHostRpcService extHostRpc: IExtHostRpcService,
@@ -93,12 +97,10 @@ export class ExtHostOutputService2 extends ExtHostOutputService {
this._logsLocation = initData.logsLocation;
}
override $setVisibleChannel(channelId: string): void {
if (channelId) {
const channel = this._channels.get(channelId);
if (channel) {
this._visibleChannelDisposable.value = channel.onDidAppend(() => channel.update());
}
override $setVisibleChannel(visibleChannelId: string | null): void {
this.visibleChannelId = visibleChannelId;
for (const [id, channel] of this._channels) {
channel.visible = id === this.visibleChannelId;
}
}
@@ -108,7 +110,10 @@ export class ExtHostOutputService2 extends ExtHostOutputService {
throw new Error('illegal argument `name`. must not be falsy');
}
const extHostOutputChannel = this._doCreateOutChannel(name, extension);
extHostOutputChannel.then(channel => channel._id.then(id => this._channels.set(id, channel)));
extHostOutputChannel.then(channel => channel._id.then(id => {
this._channels.set(id, channel);
channel.visible = id === this.visibleChannelId;
}));
return new LazyOutputChannel(name, extHostOutputChannel);
}