Skip to content

Commit

Permalink
Automatically restart clangd language server after it is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
k0zmo committed Dec 12, 2024
1 parent 17d6a42 commit 9f2f7ff
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ class UI {
}
}

private _pathUpdated: Promise<void>|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) {
Expand Down Expand Up @@ -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()
});
}
}

0 comments on commit 9f2f7ff

Please sign in to comment.