Skip to content

Commit 2b0c726

Browse files
authored
Merge pull request #20020 from Veykril/push-yuqmorzsqumw
fix: Reload workspaces when cargo configs change
2 parents c6b74f7 + 24b0666 commit 2b0c726

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

crates/rust-analyzer/src/handlers/notification.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ pub(crate) fn handle_did_change_configuration(
239239
let (config, e, _) = config.apply_change(change);
240240
this.config_errors = e.is_empty().not().then_some(e);
241241

242-
// Client config changes neccesitates .update_config method to be called.
242+
// Client config changes necessitates .update_config method to be called.
243243
this.update_configuration(config);
244244
}
245245
}

crates/rust-analyzer/src/reload.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ impl GlobalState {
114114
Durability::HIGH,
115115
);
116116
}
117+
118+
if self.config.cargo(None) != old_config.cargo(None) {
119+
let req = FetchWorkspaceRequest { path: None, force_crate_graph_reload: false };
120+
self.fetch_workspaces_queue.request_op("cargo config changed".to_owned(), req)
121+
}
122+
123+
if self.config.cfg_set_test(None) != old_config.cfg_set_test(None) {
124+
let req = FetchWorkspaceRequest { path: None, force_crate_graph_reload: false };
125+
self.fetch_workspaces_queue.request_op("cfg_set_test config changed".to_owned(), req)
126+
}
117127
}
118128

119129
pub(crate) fn current_status(&self) -> lsp_ext::ServerStatusParams {

editors/code/src/config.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,9 @@ export class Config {
2020
configureLang: vscode.Disposable | undefined;
2121

2222
readonly rootSection = "rust-analyzer";
23-
private readonly requiresServerReloadOpts = [
24-
"cargo",
25-
"procMacro",
26-
"serverPath",
27-
"server",
28-
"files",
29-
"cfg",
30-
"showSyntaxTree",
31-
].map((opt) => `${this.rootSection}.${opt}`);
23+
private readonly requiresServerReloadOpts = ["server", "files", "showSyntaxTree"].map(
24+
(opt) => `${this.rootSection}.${opt}`,
25+
);
3226

3327
private readonly requiresWindowReloadOpts = ["testExplorer"].map(
3428
(opt) => `${this.rootSection}.${opt}`,
@@ -208,7 +202,7 @@ export class Config {
208202
}
209203

210204
get serverPath() {
211-
return this.get<null | string>("server.path") ?? this.get<null | string>("serverPath");
205+
return this.get<null | string>("server.path");
212206
}
213207

214208
get serverExtraEnv(): Env {

0 commit comments

Comments
 (0)