mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
- 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:
@@ -447,7 +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;
|
||||
$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;
|
||||
|
||||
@@ -6,14 +6,12 @@
|
||||
import { MainContext, MainThreadOutputServiceShape, ExtHostOutputServiceShape } from './extHost.protocol';
|
||||
import type * as vscode from 'vscode';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { checkProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { nullExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
|
||||
|
||||
export abstract class AbstractExtHostOutputChannel extends Disposable implements vscode.OutputChannel {
|
||||
|
||||
@@ -22,17 +20,16 @@ export abstract class AbstractExtHostOutputChannel extends Disposable implements
|
||||
protected readonly _proxy: MainThreadOutputServiceShape;
|
||||
private _disposed: boolean;
|
||||
private _offset: number;
|
||||
private _extension: IExtensionDescription;
|
||||
private readonly _extension: IExtensionDescription;
|
||||
|
||||
protected readonly _onDidAppend: Emitter<void> = this._register(new Emitter<void>());
|
||||
readonly onDidAppend: Event<void> = this._onDidAppend.event;
|
||||
public visible: boolean = false;
|
||||
|
||||
constructor(name: string, log: boolean, file: URI | undefined, extension: IExtensionDescription, proxy: MainThreadOutputServiceShape) {
|
||||
super();
|
||||
|
||||
this._name = name;
|
||||
this._proxy = proxy;
|
||||
this._id = proxy.$register(this.name, log, file, extension?.identifier.value);
|
||||
this._id = proxy.$register(this.name, log, file, extension.identifier.value);
|
||||
this._disposed = false;
|
||||
this._offset = 0;
|
||||
this._extension = extension;
|
||||
@@ -44,11 +41,7 @@ export abstract class AbstractExtHostOutputChannel extends Disposable implements
|
||||
|
||||
append(value: string): void {
|
||||
this.validate();
|
||||
this._offset += value ? VSBuffer.fromString(value).byteLength : 0;
|
||||
}
|
||||
|
||||
update(): void {
|
||||
this._id.then(id => this._proxy.$update(id));
|
||||
this.incrementOffset(value);
|
||||
}
|
||||
|
||||
appendLine(value: string): void {
|
||||
@@ -62,13 +55,11 @@ export abstract class AbstractExtHostOutputChannel extends Disposable implements
|
||||
this._id.then(id => this._proxy.$clear(id, till));
|
||||
}
|
||||
|
||||
replaceAll(value: string): void {
|
||||
checkProposedApiEnabled(this._extension);
|
||||
|
||||
this.validate();
|
||||
replaceAll(value: string, donotSendValue?: boolean): void {
|
||||
this.validate(true);
|
||||
const till = this._offset;
|
||||
this._offset += value ? VSBuffer.fromString(value).byteLength : 0;
|
||||
this._id.then(id => this._proxy.$replaceAll(id, till, value));
|
||||
this.incrementOffset(value);
|
||||
this._id.then(id => this._proxy.$replaceAll(id, till, donotSendValue ? undefined : value));
|
||||
}
|
||||
|
||||
show(columnOrPreserveFocus?: vscode.ViewColumn | boolean, preserveFocus?: boolean): void {
|
||||
@@ -81,12 +72,19 @@ export abstract class AbstractExtHostOutputChannel extends Disposable implements
|
||||
this._id.then(id => this._proxy.$close(id));
|
||||
}
|
||||
|
||||
protected validate(): void {
|
||||
protected validate(checkProposedApi?: boolean): void {
|
||||
if (checkProposedApi) {
|
||||
checkProposedApiEnabled(this._extension);
|
||||
}
|
||||
if (this._disposed) {
|
||||
throw new Error('Channel has been closed');
|
||||
}
|
||||
}
|
||||
|
||||
private incrementOffset(value: string) {
|
||||
this._offset += value ? VSBuffer.fromString(value).byteLength : 0;
|
||||
}
|
||||
|
||||
override dispose(): void {
|
||||
super.dispose();
|
||||
|
||||
@@ -107,19 +105,9 @@ export class ExtHostPushOutputChannel extends AbstractExtHostOutputChannel {
|
||||
override append(value: string): void {
|
||||
super.append(value);
|
||||
this._id.then(id => this._proxy.$append(id, value));
|
||||
this._onDidAppend.fire();
|
||||
}
|
||||
}
|
||||
|
||||
class ExtHostLogFileOutputChannel extends AbstractExtHostOutputChannel {
|
||||
|
||||
constructor(name: string, file: URI, proxy: MainThreadOutputServiceShape) {
|
||||
super(name, true, file, nullExtensionDescription, proxy);
|
||||
}
|
||||
|
||||
override append(value: string): void {
|
||||
throw new Error('Not supported');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class LazyOutputChannel implements vscode.OutputChannel {
|
||||
@@ -173,16 +161,6 @@ export class ExtHostOutputService implements ExtHostOutputServiceShape {
|
||||
return new ExtHostPushOutputChannel(name, extension, this._proxy);
|
||||
}
|
||||
|
||||
createOutputChannelFromLogFile(name: string, file: URI): vscode.OutputChannel {
|
||||
name = name.trim();
|
||||
if (!name) {
|
||||
throw new Error('illegal argument `name`. must not be falsy');
|
||||
}
|
||||
if (!file) {
|
||||
throw new Error('illegal argument `file`. must not be falsy');
|
||||
}
|
||||
return new ExtHostLogFileOutputChannel(name, file, this._proxy);
|
||||
}
|
||||
}
|
||||
|
||||
export interface IExtHostOutputService extends ExtHostOutputService { }
|
||||
|
||||
Reference in New Issue
Block a user