@@ -16,14 +16,17 @@ export class Config {
16
16
readonly extensionId = "rust-lang.rust-analyzer" ;
17
17
18
18
readonly rootSection = "rust-analyzer" ;
19
+ private readonly requiresWorkspaceReloadOpts = [ "serverPath" , "server" ] . map (
20
+ ( opt ) => `${ this . rootSection } .${ opt } `
21
+ ) ;
19
22
private readonly requiresReloadOpts = [
20
- "serverPath" ,
21
- "server" ,
22
23
"cargo" ,
23
24
"procMacro" ,
24
25
"files" ,
25
26
"lens" , // works as lens.*
26
- ] . map ( ( opt ) => `${ this . rootSection } .${ opt } ` ) ;
27
+ ]
28
+ . map ( ( opt ) => `${ this . rootSection } .${ opt } ` )
29
+ . concat ( this . requiresWorkspaceReloadOpts ) ;
27
30
28
31
readonly package : {
29
32
version : string ;
@@ -60,16 +63,26 @@ export class Config {
60
63
61
64
if ( ! requiresReloadOpt ) return ;
62
65
63
- if ( this . restartServerOnConfigChange ) {
66
+ const requiresWorkspaceReloadOpt = this . requiresWorkspaceReloadOpts . find ( ( opt ) =>
67
+ event . affectsConfiguration ( opt )
68
+ ) ;
69
+
70
+ if ( ! requiresWorkspaceReloadOpt && this . restartServerOnConfigChange ) {
64
71
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" ) ;
70
79
80
+ if ( userResponse === "Reload now" ) {
81
+ const command = requiresWorkspaceReloadOpt
82
+ ? "workbench.action.reloadWindow"
83
+ : "rust-analyzer.reload" ;
71
84
if ( userResponse === "Reload now" ) {
72
- await vscode . commands . executeCommand ( "rust-analyzer.reload" ) ;
85
+ await vscode . commands . executeCommand ( command ) ;
73
86
}
74
87
}
75
88
}
0 commit comments