Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure LSP server is shutdown on extension exit #224

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion bundled/tool/lsp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,13 @@ def initialize(params: lsp.InitializeParams) -> None:


@LSP_SERVER.feature(lsp.EXIT)
def on_exit():
def on_exit(_params: Optional[Any] = None):
"""Handle clean up on exit."""
jsonrpc.shutdown_json_rpc()


@LSP_SERVER.feature(lsp.SHUTDOWN)
def on_shutdown(_params: Optional[Any] = None):
"""Handle clean up on exit."""
jsonrpc.shutdown_json_rpc()

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import * as vscode from 'vscode';
import { LanguageClient } from 'vscode-languageclient/node';
import { restartServer } from './common/server';
import { registerLogger, setLoggingLevel, traceLog, traceVerbose } from './common/log/logging';
import { OutputChannelLogger } from './common/log/outputChannelLogger';
import {
Expand All @@ -12,6 +11,7 @@ import {
onDidChangePythonInterpreter,
runPythonExtensionCommand,
} from './common/python';
import { restartServer } from './common/server';
import {
checkIfConfigurationChanged,
getExtensionSettings,
Expand All @@ -20,9 +20,9 @@ import {
ISettings,
} from './common/settings';
import { loadServerDefaults } from './common/setup';
import { createOutputChannel, onDidChangeConfiguration, registerCommand } from './common/vscodeapi';
import { getProjectRoot } from './common/utilities';
import { registerSortImportFeatures } from './common/sortImports';
import { getProjectRoot } from './common/utilities';
import { createOutputChannel, onDidChangeConfiguration, registerCommand } from './common/vscodeapi';

let lsClient: LanguageClient | undefined;
export async function activate(context: vscode.ExtensionContext): Promise<void> {
Expand Down Expand Up @@ -94,3 +94,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
}
});
}

export async function deactivate(): Promise<void> {
if (lsClient) {
await lsClient.stop();
}
}