Skip to content

Commit 213fe57

Browse files
committed
Add restartServerOnConfigChange setting
1 parent 92241d6 commit 213fe57

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

editors/code/package.json

Lines changed: 5 additions & 0 deletions
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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,18 @@ export class Config {
6060

6161
if (!requiresReloadOpt) return;
6262

63-
await vscode.commands.executeCommand("rust-analyzer.reload");
63+
if (this.restartServerOnConfigChange) {
64+
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+
}
74+
}
6475
}
6576

6677
// We don't do runtime config validation here for simplicity. More on stackoverflow:
@@ -112,6 +123,10 @@ export class Config {
112123
return this.get<RunnableEnvCfg>("runnableEnv");
113124
}
114125

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

0 commit comments

Comments
 (0)