From ff43647be3c39d175ee39750ed3e828828c6a22c Mon Sep 17 00:00:00 2001 From: k0zmo Date: Tue, 17 Dec 2024 09:21:53 +0100 Subject: [PATCH] Automatically restart clangd language server after it is installed --- src/install.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/install.ts b/src/install.ts index b333c40..a766d4c 100644 --- a/src/install.ts +++ b/src/install.ts @@ -81,9 +81,13 @@ class UI { } } + private _pathUpdated: Promise|null = null; + async promptReload(message: string) { - if (await vscode.window.showInformationMessage(message, 'Reload window')) - vscode.commands.executeCommand('workbench.action.reloadWindow'); + vscode.window.showInformationMessage(message) + await this._pathUpdated; + this._pathUpdated = null; + vscode.commands.executeCommand('clangd.restart'); } async showHelp(message: string, url: string) { @@ -129,6 +133,8 @@ class UI { return p; } set clangdPath(p: string) { - config.update('path', p, vscode.ConfigurationTarget.Global); + this._pathUpdated = new Promise(resolve => { + config.update('path', p, vscode.ConfigurationTarget.Global).then(resolve); + }); } }