Skip to content

Commit 9098111

Browse files
committed
Use single output channel for LSP
Since there is only one session active at a time
1 parent 1fe4f7e commit 9098111

File tree

2 files changed

+13
-72
lines changed

2 files changed

+13
-72
lines changed

extensions/positron-r/src/lsp-output-channel-manager.ts

Lines changed: 0 additions & 58 deletions
This file was deleted.

extensions/positron-r/src/lsp.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,19 @@ import {
2020

2121
import { Socket } from 'net';
2222
import { RHelpTopicProvider } from './help';
23-
import { RLspOutputChannelManager } from './lsp-output-channel-manager';
2423
import { R_DOCUMENT_SELECTORS } from './provider';
2524
import { VirtualDocumentProvider } from './virtual-documents';
2625

26+
/**
27+
* Global output channel for R LSP sessions
28+
*
29+
* Since we only have one LSP session active at any time, and since the start of
30+
* a new session is logged with a session ID, we use a single output channel for
31+
* all LSP sessions. Watch out for session start log messages to find the
32+
* relevant section of the log.
33+
*/
34+
const LSP_OUTPUT_CHANNEL = positron.window.createRawLogOutputChannel('R Language Server');
35+
2736
/**
2837
* The state of the language server.
2938
*/
@@ -107,12 +116,6 @@ export class ArkLsp implements vscode.Disposable {
107116

108117
const { notebookUri } = this._metadata;
109118

110-
// Persistant output channel, used across multiple sessions of the same name + mode combination
111-
const outputChannel = RLspOutputChannelManager.instance.getOutputChannel(
112-
this._dynState.sessionName,
113-
this._metadata.sessionMode
114-
);
115-
116119
const clientOptions: LanguageClientOptions = {
117120
// If this client belongs to a notebook, set the document selector to only include that notebook.
118121
// Otherwise, this is the main client for this language, so set the document selector to include
@@ -126,7 +129,7 @@ export class ArkLsp implements vscode.Disposable {
126129
fileEvents: vscode.workspace.createFileSystemWatcher('**/*.R')
127130
},
128131
errorHandler: new RErrorHandler(this._version, port),
129-
outputChannel: outputChannel,
132+
outputChannel: LSP_OUTPUT_CHANNEL,
130133
revealOutputChannelOn: RevealOutputChannelOn.Never,
131134
middleware: {
132135
handleDiagnostics(uri, diagnostics, next) {
@@ -146,7 +149,7 @@ export class ArkLsp implements vscode.Disposable {
146149
const message = `Creating language client ${this._dynState.sessionName} for session ${this._metadata.sessionId} on port ${port}`;
147150

148151
LOGGER.info(message);
149-
outputChannel.appendLine(message);
152+
LSP_OUTPUT_CHANNEL.appendLine(message);
150153

151154
this.client = new LanguageClient(id, this.languageClientName, serverOptions, clientOptions);
152155

@@ -319,10 +322,6 @@ export class ArkLsp implements vscode.Disposable {
319322
}
320323

321324
public showOutput() {
322-
const outputChannel = RLspOutputChannelManager.instance.getOutputChannel(
323-
this._dynState.sessionName,
324-
this._metadata.sessionMode
325-
);
326-
outputChannel.show();
325+
LSP_OUTPUT_CHANNEL.show();
327326
}
328327
}

0 commit comments

Comments
 (0)