Skip to content

Commit 22b5e9d

Browse files
committed
dispose subscriptions if language-server extension added
1 parent 5265fb6 commit 22b5e9d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/extension.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,14 +535,15 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
535535
}
536536

537537
const languageServerExt = languageServer();
538+
const noLSsubscriptions: { dispose(): any }[] = [];
538539
if (!languageServerExt) {
539540
outputChannel.appendLine(`The language-server extension was not found.\n`);
540541
outputChannel.show(true);
541542

542543
if (vscode.window.activeTextEditor) {
543544
diagnosticProvider.updateDiagnostics(vscode.window.activeTextEditor.document);
544545
}
545-
context.subscriptions.push(
546+
noLSsubscriptions.push(
546547
workspace.onDidChangeTextDocument((event) => {
547548
diagnosticProvider.updateDiagnostics(event.document);
548549
}),
@@ -576,10 +577,19 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
576577
"#"
577578
)
578579
);
580+
context.subscriptions.push(...noLSsubscriptions);
579581
}
580582

581583
context.subscriptions.push(
582584
reporter,
585+
vscode.extensions.onDidChange(() => {
586+
const languageServerExt2 = languageServer();
587+
if (typeof languageServerExt !== typeof languageServerExt2) {
588+
noLSsubscriptions.forEach((event) => {
589+
event.dispose();
590+
});
591+
}
592+
}),
583593
workspace.onDidChangeTextDocument((event) => {
584594
if (
585595
event.contentChanges.length !== 0 &&

0 commit comments

Comments
 (0)