mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 14:13:58 +00:00
Auto merge of #14067 - jonas-schievink:lazy-trace-output, r=jonas-schievink
fix: Lazily create the trace output channel Fixes https://github.com/rust-lang/rust-analyzer/issues/13055
This commit is contained in:
commit
0fcef7fdd3
2 changed files with 48 additions and 4 deletions
|
@ -4,7 +4,7 @@ import * as ra from "./lsp_ext";
|
|||
|
||||
import { Config, substituteVSCodeVariables } from "./config";
|
||||
import { createClient } from "./client";
|
||||
import { isRustDocument, isRustEditor, log, RustEditor } from "./util";
|
||||
import { isRustDocument, isRustEditor, LazyOutputChannel, log, RustEditor } from "./util";
|
||||
import { ServerStatusParams } from "./lsp_ext";
|
||||
import { PersistentState } from "./persistent_state";
|
||||
import { bootstrap } from "./bootstrap";
|
||||
|
@ -128,9 +128,7 @@ export class Ctx {
|
|||
}
|
||||
|
||||
if (!this.traceOutputChannel) {
|
||||
this.traceOutputChannel = vscode.window.createOutputChannel(
|
||||
"Rust Analyzer Language Server Trace"
|
||||
);
|
||||
this.traceOutputChannel = new LazyOutputChannel("Rust Analyzer Language Server Trace");
|
||||
this.pushExtCleanup(this.traceOutputChannel);
|
||||
}
|
||||
if (!this.outputChannel) {
|
||||
|
|
|
@ -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?: any, preserveFocus?: any): void {
|
||||
this.channel.show(column, preserveFocus);
|
||||
}
|
||||
hide(): void {
|
||||
if (this._channel) {
|
||||
this._channel.hide();
|
||||
}
|
||||
}
|
||||
dispose(): void {
|
||||
if (this._channel) {
|
||||
this._channel.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue