This commit is contained in:
Sandeep Somavarapu
2018-09-26 16:19:07 +02:00
parent e02fad2a63
commit 5de0fbbb1d
5 changed files with 32 additions and 14 deletions

View File

@@ -38,11 +38,13 @@ export class MainThreadOutputService extends Disposable implements MainThreadOut
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostOutputService);
this._register(anyEvent<any>(this._outputService.onActiveOutputChannel, this._panelService.onDidPanelOpen, this._panelService.onDidPanelClose)(() => {
const setVisibleChannel = () => {
const panel = this._panelService.getActivePanel();
const visibleChannel: IOutputChannel = panel && panel.getId() === OUTPUT_PANEL_ID ? this._outputService.getActiveChannel() : null;
this._proxy.$setVisibleChannel(visibleChannel ? visibleChannel.id : null);
}));
};
this._register(anyEvent<any>(this._outputService.onActiveOutputChannel, this._panelService.onDidPanelOpen, this._panelService.onDidPanelClose)(() => setVisibleChannel()));
setVisibleChannel();
}
public dispose(): void {
@@ -72,10 +74,10 @@ export class MainThreadOutputService extends Disposable implements MainThreadOut
return undefined;
}
public $clear(channelId: string): Thenable<void> {
public $clear(channelId: string, till: number): Thenable<void> {
const channel = this._getChannel(channelId);
if (channel) {
channel.clear();
channel.clear(till);
}
return undefined;
}

View File

@@ -305,7 +305,7 @@ export interface MainThreadOutputServiceShape extends IDisposable {
$register(label: string, log: boolean, file?: UriComponents): Thenable<string>;
$append(channelId: string, value: string): Thenable<void>;
$update(channelId: string): Thenable<void>;
$clear(channelId: string): Thenable<void>;
$clear(channelId: string, till: number): Thenable<void>;
$reveal(channelId: string, preserveFocus: boolean): Thenable<void>;
$close(channelId: string): Thenable<void>;
$dispose(channelId: string): Thenable<void>;

View File

@@ -19,6 +19,7 @@ export abstract class AbstractExtHostOutputChannel extends Disposable implements
private readonly _name: string;
protected readonly _proxy: MainThreadOutputServiceShape;
private _disposed: boolean;
private _offset: number;
protected _onDidAppend: Emitter<void> = this._register(new Emitter<void>());
get onDidAppend(): Event<void> { return this._onDidAppend.event; }
@@ -29,13 +30,17 @@ export abstract class AbstractExtHostOutputChannel extends Disposable implements
this._name = name;
this._proxy = proxy;
this._id = proxy.$register(this.name, log, file);
this._offset = 0;
}
get name(): string {
return this._name;
}
abstract append(value: string): void;
append(value: string): void {
this.validate();
this._offset += value ? Buffer.from(value).byteLength : 0;
}
update(): void {
this._id.then(id => this._proxy.$update(id));
@@ -48,7 +53,8 @@ export abstract class AbstractExtHostOutputChannel extends Disposable implements
clear(): void {
this.validate();
this._id.then(id => this._proxy.$clear(id));
const till = this._offset;
this._id.then(id => this._proxy.$clear(id, till));
}
show(columnOrPreserveFocus?: vscode.ViewColumn | boolean, preserveFocus?: boolean): void {
@@ -85,7 +91,7 @@ export class ExtHostPushOutputChannel extends AbstractExtHostOutputChannel {
}
append(value: string): void {
this.validate();
super.append(value);
this._id.then(id => this._proxy.$append(id, value));
this._onDidAppend.fire();
}
@@ -105,7 +111,7 @@ export class ExtHostOutputChannelBackedByFile extends AbstractExtHostOutputChann
}
append(value: string): void {
this.validate();
super.append(value);
this._appender.append(value);
this._onDidAppend.fire();
}