Skip to content

Commit 745230c

Browse files
committed
Auto merge of rust-lang#12477 - hasali19:auto-reload, r=Veykril
Restart server automatically on settings changes Closes rust-lang#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.
2 parents 0bbead9 + 213fe57 commit 745230c

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

editors/code/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,11 @@
11151115
"Search in current workspace and dependencies."
11161116
]
11171117
},
1118+
"rust-analyzer.restartServerOnConfigChange": {
1119+
"markdownDescription": "Whether to restart the server automatically when certain settings that require a restart are changed.",
1120+
"default": false,
1121+
"type": "boolean"
1122+
},
11181123
"$generated-end": {}
11191124
}
11201125
},

editors/code/src/config.ts

+14-6
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,17 @@ export class Config {
6060

6161
if (!requiresReloadOpt) return;
6262

63-
const userResponse = await vscode.window.showInformationMessage(
64-
`Changing "${requiresReloadOpt}" requires a reload`,
65-
"Reload now"
66-
);
67-
68-
if (userResponse === "Reload now") {
63+
if (this.restartServerOnConfigChange) {
6964
await vscode.commands.executeCommand("rust-analyzer.reload");
65+
} else {
66+
const userResponse = await vscode.window.showInformationMessage(
67+
`Changing "${requiresReloadOpt}" requires a reload`,
68+
"Reload now"
69+
);
70+
71+
if (userResponse === "Reload now") {
72+
await vscode.commands.executeCommand("rust-analyzer.reload");
73+
}
7074
}
7175
}
7276

@@ -119,6 +123,10 @@ export class Config {
119123
return this.get<RunnableEnvCfg>("runnableEnv");
120124
}
121125

126+
get restartServerOnConfigChange() {
127+
return this.get<boolean>("restartServerOnConfigChange");
128+
}
129+
122130
get debug() {
123131
let sourceFileMap = this.get<Record<string, string> | "auto">("debug.sourceFileMap");
124132
if (sourceFileMap !== "auto") {

0 commit comments

Comments
 (0)