Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically restart clangd language server after it is installed #749

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ class UI {
}
}

private _pathUpdated: Promise<void>|null = null;

async promptReload(message: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should ignore message entirely. Can we still show it in an info dialog, without waiting for the user to interact with it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do this:

  async promptReload(message: string) {
    vscode.window.showInformationMessage(message)
    await this._pathUpdated;
    this._pathUpdated = null;
    vscode.commands.executeCommand('clangd.restart');
  }

Without await, this won't wait for user prompt and it would serve as a status message 'clangd ${version} is installed'. Is this what you had in mind?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, exactly

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) {
Expand Down Expand Up @@ -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);
});
}
}
Loading