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 9, 2024
1 parent 17d6a42 commit bb1d370
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 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,10 @@ 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 bb1d370

Please sign in to comment.