Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #12477 - hasali19:auto-reload, r=Veykril
Restart server automatically on settings changes Closes #12476 I think this works quite well, but if you think it would be better to put it behind a setting I can do that.
bors 2022-06-11
parent 0bbead9 · parent 213fe57 · commit 745230c
-rw-r--r--editors/code/package.json5
-rw-r--r--editors/code/src/config.ts20
2 files changed, 19 insertions, 6 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index 03ec18a568..e56583e63b 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -1115,6 +1115,11 @@
"Search in current workspace and dependencies."
]
},
+ "rust-analyzer.restartServerOnConfigChange": {
+ "markdownDescription": "Whether to restart the server automatically when certain settings that require a restart are changed.",
+ "default": false,
+ "type": "boolean"
+ },
"$generated-end": {}
}
},
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index dba3421978..c9ca235ed5 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -60,13 +60,17 @@ export class Config {
if (!requiresReloadOpt) return;
- const userResponse = await vscode.window.showInformationMessage(
- `Changing "${requiresReloadOpt}" requires a reload`,
- "Reload now"
- );
-
- if (userResponse === "Reload now") {
+ if (this.restartServerOnConfigChange) {
await vscode.commands.executeCommand("rust-analyzer.reload");
+ } else {
+ const userResponse = await vscode.window.showInformationMessage(
+ `Changing "${requiresReloadOpt}" requires a reload`,
+ "Reload now"
+ );
+
+ if (userResponse === "Reload now") {
+ await vscode.commands.executeCommand("rust-analyzer.reload");
+ }
}
}
@@ -119,6 +123,10 @@ export class Config {
return this.get<RunnableEnvCfg>("runnableEnv");
}
+ get restartServerOnConfigChange() {
+ return this.get<boolean>("restartServerOnConfigChange");
+ }
+
get debug() {
let sourceFileMap = this.get<Record<string, string> | "auto">("debug.sourceFileMap");
if (sourceFileMap !== "auto") {