Skip to content

Commit 9f2f7ff

Browse files
committed
Automatically restart clangd language server after it is installed
1 parent 17d6a42 commit 9f2f7ff

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/install.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,12 @@ class UI {
8181
}
8282
}
8383

84+
private _pathUpdated: Promise<void>|undefined;
85+
private _resolvePathUpdated: (() => void)|undefined;
86+
8487
async promptReload(message: string) {
85-
if (await vscode.window.showInformationMessage(message, 'Reload window'))
86-
vscode.commands.executeCommand('workbench.action.reloadWindow');
88+
await this._pathUpdated
89+
vscode.commands.executeCommand('clangd.restart')
8790
}
8891

8992
async showHelp(message: string, url: string) {
@@ -129,6 +132,11 @@ class UI {
129132
return p;
130133
}
131134
set clangdPath(p: string) {
132-
config.update('path', p, vscode.ConfigurationTarget.Global);
135+
this._pathUpdated =
136+
new Promise(resolve => this._resolvePathUpdated = resolve)
137+
config.update('path', p, vscode.ConfigurationTarget.Global).then(() => {
138+
if (this._resolvePathUpdated)
139+
this._resolvePathUpdated()
140+
});
133141
}
134142
}

0 commit comments

Comments
 (0)