diff --git a/src/env.ts b/src/env.ts index e6f2170..b2a5b17 100644 --- a/src/env.ts +++ b/src/env.ts @@ -169,9 +169,6 @@ export class Environment { } get client(): LanguageClient | null { - if (!this._client) { - window.showWarningMessage("Semgrep Language Server not active"); - } return this._client; } diff --git a/src/lsp.ts b/src/lsp.ts index 897d371..843236d 100644 --- a/src/lsp.ts +++ b/src/lsp.ts @@ -220,6 +220,12 @@ async function start(env: Environment): Promise { // TODO: Remove when semgrep is no longer experimental on Windows. if (process.platform === "win32") process.env.SEMGREP_FORCE_INSTALL = "1"; + if (env.client) { + env.logger.log("Language client already running, stopping it..."); + await env.client.stop(); + env.client = null; + } + // Compute LSP server and client options const [serverOptions, clientOptions] = await lspOptions(env); @@ -266,10 +272,7 @@ async function stop(env: Environment | null): Promise { if (!client) { return; } - await client.sendRequest("shutdown"); - env?.logger.log("Exiting"); - await client.sendNotification("exit"); - client.stop(); + await client.stop(); env?.logger.log("Language client stopped..."); }