Add replaceAll method to OutputChannel to improve render flickering for extensions with minimal output contents; associated with https://github.com/microsoft/vscode/issues/132183

This commit is contained in:
Simon McEnlly
2021-11-03 15:35:53 +10:00
parent f961b92f0f
commit 0603dcd867
8 changed files with 182 additions and 9 deletions

View File

@@ -447,6 +447,7 @@ export interface MainThreadOutputServiceShape extends IDisposable {
$append(channelId: string, value: string): Promise<void> | undefined;
$update(channelId: string): Promise<void> | undefined;
$clear(channelId: string, till: number): Promise<void> | undefined;
$replaceAll(channelId: string, till: number, value: string): Promise<void> | undefined;
$reveal(channelId: string, preserveFocus: boolean): Promise<void> | undefined;
$close(channelId: string): Promise<void> | undefined;
$dispose(channelId: string): Promise<void> | undefined;

View File

@@ -58,6 +58,13 @@ export abstract class AbstractExtHostOutputChannel extends Disposable implements
this._id.then(id => this._proxy.$clear(id, till));
}
replaceAll(value: string): void {
this.validate();
const till = this._offset;
this._offset += value ? VSBuffer.fromString(value).byteLength : 0;
this._id.then(id => this._proxy.$replaceAll(id, till, value));
}
show(columnOrPreserveFocus?: vscode.ViewColumn | boolean, preserveFocus?: boolean): void {
this.validate();
this._id.then(id => this._proxy.$reveal(id, !!(typeof columnOrPreserveFocus === 'boolean' ? columnOrPreserveFocus : preserveFocus)));
@@ -125,6 +132,9 @@ export class LazyOutputChannel implements vscode.OutputChannel {
clear(): void {
this._channel.then(channel => channel.clear());
}
replaceAll(value: string): void {
this._channel.then(channel => channel.replaceAll(value));
}
show(columnOrPreserveFocus?: vscode.ViewColumn | boolean, preserveFocus?: boolean): void {
this._channel.then(channel => channel.show(columnOrPreserveFocus, preserveFocus));
}