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