diff options
| author | Jonas Schievink <jonas.schievink@ferrous-systems.com> | 2023-01-31 15:43:47 +0100 |
|---|---|---|
| committer | Jonas Schievink <jonas.schievink@ferrous-systems.com> | 2023-01-31 15:43:47 +0100 |
| commit | 56f81ebc3e52ac7e6dd8a3359e290d8765975edc (patch) | |
| tree | 8e8be005ade8930cb039b79edf8952fb191b2040 /editors/code/src/util.ts | |
| parent | d805c74c51888b3308c7577e747d50d6a6f1dc9b (diff) | |
| download | rust-56f81ebc3e52ac7e6dd8a3359e290d8765975edc.tar.gz rust-56f81ebc3e52ac7e6dd8a3359e290d8765975edc.zip | |
Lazily create the trace output channel
Diffstat (limited to 'editors/code/src/util.ts')
| -rw-r--r-- | editors/code/src/util.ts | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index a92c90f7ff4..33d42986ad9 100644 --- a/editors/code/src/util.ts +++ b/editors/code/src/util.ts @@ -166,3 +166,49 @@ export function execute(command: string, options: ExecOptions): Promise<string> }); }); } + +export class LazyOutputChannel implements vscode.OutputChannel { + constructor(name: string) { + this.name = name; + } + + name: string; + _channel: vscode.OutputChannel | undefined; + + get channel(): vscode.OutputChannel { + if (!this._channel) { + this._channel = vscode.window.createOutputChannel(this.name); + } + return this._channel; + } + + append(value: string): void { + this.channel.append(value); + } + appendLine(value: string): void { + this.channel.appendLine(value); + } + replace(value: string): void { + this.channel.replace(value); + } + clear(): void { + if (this._channel) { + this._channel.clear(); + } + } + show(preserveFocus?: boolean): void; + show(column?: vscode.ViewColumn, preserveFocus?: boolean): void; + show(column?: vscode.ViewColumn, preserveFocus?: boolean): void { + this.channel.show(column, preserveFocus); + } + hide(): void { + if (this._channel) { + this._channel.hide(); + } + } + dispose(): void { + if (this._channel) { + this._channel.dispose(); + } + } +} |
