Skip to content

Commit eb89833

Browse files
committed
Make channel creation lazy
1 parent 09f4666 commit eb89833

File tree

1 file changed

+10
-4
lines changed
  • extensions/positron-r/src

1 file changed

+10
-4
lines changed

extensions/positron-r/src/lsp.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ import { VirtualDocumentProvider } from './virtual-documents';
3131
* all LSP sessions. Watch out for session start log messages to find the
3232
* relevant section of the log.
3333
*/
34-
const LSP_OUTPUT_CHANNEL = positron.window.createRawLogOutputChannel('R Language Server');
34+
let _lspOutputChannel: vscode.OutputChannel | undefined;
35+
function getLspOutputChannel(): vscode.OutputChannel {
36+
if (!_lspOutputChannel) {
37+
_lspOutputChannel = positron.window.createRawLogOutputChannel('R Language Server');
38+
}
39+
return _lspOutputChannel;
40+
}
3541

3642
/**
3743
* The state of the language server.
@@ -129,7 +135,7 @@ export class ArkLsp implements vscode.Disposable {
129135
fileEvents: vscode.workspace.createFileSystemWatcher('**/*.R')
130136
},
131137
errorHandler: new RErrorHandler(this._version, port),
132-
outputChannel: LSP_OUTPUT_CHANNEL,
138+
outputChannel: getLspOutputChannel(),
133139
revealOutputChannelOn: RevealOutputChannelOn.Never,
134140
middleware: {
135141
handleDiagnostics(uri, diagnostics, next) {
@@ -149,7 +155,7 @@ export class ArkLsp implements vscode.Disposable {
149155
const message = `Creating language client ${this._dynState.sessionName} for session ${this._metadata.sessionId} on port ${port}`;
150156

151157
LOGGER.info(message);
152-
LSP_OUTPUT_CHANNEL.appendLine(message);
158+
getLspOutputChannel().appendLine(message);
153159

154160
this.client = new LanguageClient(id, this.languageClientName, serverOptions, clientOptions);
155161

@@ -322,6 +328,6 @@ export class ArkLsp implements vscode.Disposable {
322328
}
323329

324330
public showOutput() {
325-
LSP_OUTPUT_CHANNEL.show();
331+
getLspOutputChannel().show();
326332
}
327333
}

0 commit comments

Comments
 (0)