Skip to content

Commit

Permalink
Ensure LSP server is shutdown on extension exit (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig authored Feb 3, 2023
1 parent 6a54c2a commit b2d1c6d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bundled/tool/lsp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,17 @@ def initialize(params: lsp.InitializeParams) -> None:


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


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


def _log_version_info() -> None:
for value in WORKSPACE_SETTINGS.values():
try:
Expand Down
6 changes: 6 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,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 b2d1c6d

Please sign in to comment.