@@ -16,14 +16,17 @@ export class Config {
1616 readonly extensionId = "rust-lang.rust-analyzer" ;
1717
1818 readonly rootSection = "rust-analyzer" ;
19+ private readonly requiresWorkspaceReloadOpts = [ "serverPath" , "server" ] . map (
20+ ( opt ) => `${ this . rootSection } .${ opt } `
21+ ) ;
1922 private readonly requiresReloadOpts = [
20- "serverPath" ,
21- "server" ,
2223 "cargo" ,
2324 "procMacro" ,
2425 "files" ,
2526 "lens" , // works as lens.*
26- ] . map ( ( opt ) => `${ this . rootSection } .${ opt } ` ) ;
27+ ]
28+ . map ( ( opt ) => `${ this . rootSection } .${ opt } ` )
29+ . concat ( this . requiresWorkspaceReloadOpts ) ;
2730
2831 readonly package : {
2932 version : string ;
@@ -60,16 +63,26 @@ export class Config {
6063
6164 if ( ! requiresReloadOpt ) return ;
6265
63- if ( this . restartServerOnConfigChange ) {
66+ const requiresWorkspaceReloadOpt = this . requiresWorkspaceReloadOpts . find ( ( opt ) =>
67+ event . affectsConfiguration ( opt )
68+ ) ;
69+
70+ if ( ! requiresWorkspaceReloadOpt && this . restartServerOnConfigChange ) {
6471 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- ) ;
72+ return ;
73+ }
74+
75+ const message = requiresWorkspaceReloadOpt
76+ ? `Changing "${ requiresWorkspaceReloadOpt } " requires a window reload`
77+ : `Changing "${ requiresReloadOpt } " requires a reload` ;
78+ const userResponse = await vscode . window . showInformationMessage ( message , "Reload now" ) ;
7079
80+ if ( userResponse === "Reload now" ) {
81+ const command = requiresWorkspaceReloadOpt
82+ ? "workbench.action.reloadWindow"
83+ : "rust-analyzer.reload" ;
7184 if ( userResponse === "Reload now" ) {
72- await vscode . commands . executeCommand ( "rust-analyzer.reload" ) ;
85+ await vscode . commands . executeCommand ( command ) ;
7386 }
7487 }
7588 }
0 commit comments