From ffc2058e99decc2c1d760116d7a7039d798d85dd Mon Sep 17 00:00:00 2001 From: Techatrix Date: Mon, 30 Dec 2024 02:47:52 +0100 Subject: [PATCH 1/2] debounce the refreshZigInstallation function --- src/zigSetup.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/zigSetup.ts b/src/zigSetup.ts index 995d0fa..2bcdd13 100644 --- a/src/zigSetup.ts +++ b/src/zigSetup.ts @@ -3,6 +3,7 @@ import vscode from "vscode"; import path from "path"; import axios from "axios"; +import { debounce } from "lodash-es"; import semver from "semver"; import * as minisign from "./minisign"; @@ -452,7 +453,7 @@ export async function setupZig(context: vscode.ExtensionContext) { const watcher1 = vscode.workspace.createFileSystemWatcher("**/.zigversion"); const watcher2 = vscode.workspace.createFileSystemWatcher("**/build.zig.zon"); - const refreshZigInstallation = async () => { + const refreshZigInstallation = debounce(async () => { if (!vscode.workspace.getConfiguration("zig").get("path")) { await installZig(context); } else { @@ -460,7 +461,7 @@ export async function setupZig(context: vscode.ExtensionContext) { updateLanguageStatusItem(languageStatusItem, zigProvider.getZigVersion()); updateZigEnvironmentVariableCollection(context, zigProvider.getZigPath()); } - }; + }, 200); const onDidChangeActiveTextEditor = (editor: vscode.TextEditor | undefined) => { if (editor?.document.languageId === "zig") { From 840c16e7d4ad93c427eedfbc70406da1b5922755 Mon Sep 17 00:00:00 2001 From: Techatrix Date: Mon, 30 Dec 2024 02:52:13 +0100 Subject: [PATCH 2/2] don't await stopClient to make sure that ZLS is not started twice --- src/zls.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/zls.ts b/src/zls.ts index 22044f5..0abb236 100644 --- a/src/zls.ts +++ b/src/zls.ts @@ -41,7 +41,7 @@ export async function restartClient(context: vscode.ExtensionContext): Promise { if (!client) return; + const oldClient = client; + client = null; // The `stop` call will send the "shutdown" notification to the LSP - await client.stop(); + await oldClient.stop(); // The `dipose` call will send the "exit" request to the LSP which actually tells the child process to exit - await client.dispose(); - client = null; + await oldClient.dispose(); } /** returns the file system path to the zls executable */