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 498defa4cb..c9ca235ed5 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -60,7 +60,18 @@ export class Config { if (!requiresReloadOpt) return; - await vscode.commands.executeCommand("rust-analyzer.reload"); + 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"); + } + } } // We don't do runtime config validation here for simplicity. More on stackoverflow: @@ -112,6 +123,10 @@ export class Config { return this.get("runnableEnv"); } + get restartServerOnConfigChange() { + return this.get("restartServerOnConfigChange"); + } + get debug() { let sourceFileMap = this.get | "auto">("debug.sourceFileMap"); if (sourceFileMap !== "auto") {