mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-16 23:36:13 +00:00
Lazily create the trace output channel
This commit is contained in:
parent
d805c74c51
commit
56f81ebc3e
2 changed files with 48 additions and 4 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue