Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/config.ts')
-rw-r--r--editors/code/src/config.ts33
1 files changed, 23 insertions, 10 deletions
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index c9ca235ed5..b04f18890b 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -16,14 +16,17 @@ export class Config {
readonly extensionId = "rust-lang.rust-analyzer";
readonly rootSection = "rust-analyzer";
+ private readonly requiresWorkspaceReloadOpts = ["serverPath", "server"].map(
+ (opt) => `${this.rootSection}.${opt}`
+ );
private readonly requiresReloadOpts = [
- "serverPath",
- "server",
"cargo",
"procMacro",
"files",
"lens", // works as lens.*
- ].map((opt) => `${this.rootSection}.${opt}`);
+ ]
+ .map((opt) => `${this.rootSection}.${opt}`)
+ .concat(this.requiresWorkspaceReloadOpts);
readonly package: {
version: string;
@@ -60,16 +63,26 @@ export class Config {
if (!requiresReloadOpt) return;
- if (this.restartServerOnConfigChange) {
+ const requiresWorkspaceReloadOpt = this.requiresWorkspaceReloadOpts.find((opt) =>
+ event.affectsConfiguration(opt)
+ );
+
+ if (!requiresWorkspaceReloadOpt && this.restartServerOnConfigChange) {
await vscode.commands.executeCommand("rust-analyzer.reload");
- } else {
- const userResponse = await vscode.window.showInformationMessage(
- `Changing "${requiresReloadOpt}" requires a reload`,
- "Reload now"
- );
+ return;
+ }
+
+ const message = requiresWorkspaceReloadOpt
+ ? `Changing "${requiresWorkspaceReloadOpt}" requires a window reload`
+ : `Changing "${requiresReloadOpt}" requires a reload`;
+ const userResponse = await vscode.window.showInformationMessage(message, "Reload now");
+ if (userResponse === "Reload now") {
+ const command = requiresWorkspaceReloadOpt
+ ? "workbench.action.reloadWindow"
+ : "rust-analyzer.reload";
if (userResponse === "Reload now") {
- await vscode.commands.executeCommand("rust-analyzer.reload");
+ await vscode.commands.executeCommand(command);
}
}
}