Skip to content

Commit

Permalink
Ensure LSP server is shutdown. (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig authored Feb 3, 2023
1 parent 262e929 commit fcc6ade
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
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();
}
}

0 comments on commit fcc6ade

Please sign in to comment.