From 02c75ebcb89a0c5cef9919da333dbef172c57e88 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Tue, 21 Jan 2025 10:27:55 +0530 Subject: [PATCH] Use extension context for output window disposable --- src/common/server.ts | 9 ++++++--- src/extension.ts | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/common/server.ts b/src/common/server.ts index abc53898..b19fca4e 100644 --- a/src/common/server.ts +++ b/src/common/server.ts @@ -416,6 +416,7 @@ async function createServer( let _disposables: Disposable[] = []; export async function startServer( + context: vscode.ExtensionContext, projectRoot: vscode.WorkspaceFolder, workspaceSettings: ISettings, serverId: string, @@ -425,11 +426,13 @@ export async function startServer( // Create output channels for the server and trace logs const outputChannel = vscode.window.createOutputChannel(`${serverName} Language Server`); - _disposables.push(outputChannel); + context.subscriptions.push(outputChannel); const traceOutputChannel = new LazyOutputChannel(`${serverName} Language Server Trace`); - _disposables.push(traceOutputChannel); + context.subscriptions.push(traceOutputChannel); // And, a command to show the server logs - _disposables.push(registerCommand(`${serverId}.showServerLogs`, () => outputChannel.show())); + context.subscriptions.push( + registerCommand(`${serverId}.showServerLogs`, () => outputChannel.show()), + ); const extensionSettings = await getExtensionSettings(serverId); const globalSettings = await getGlobalSettings(serverId); diff --git a/src/extension.ts b/src/extension.ts index 29119264..967b73ca 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -127,7 +127,7 @@ export async function activate(context: vscode.ExtensionContext): Promise } } - lsClient = await startServer(projectRoot, workspaceSettings, serverId, serverName); + lsClient = await startServer(context, projectRoot, workspaceSettings, serverId, serverName); } finally { // Ensure that we reset the flag in case of an error, early return, or success. restartInProgress = false;