Skip to content

Commit e3c47cc

Browse files
committed
Use autoreload config to gate execution rather that staleness
1 parent 3698b3e commit e3c47cc

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

crates/rust-analyzer/src/main_loop.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,9 @@ impl GlobalState {
454454
}
455455
}
456456

457-
self.fetch_workspaces_if_needed();
457+
if self.config.cargo_autoreload() {
458+
self.fetch_workspaces_if_needed();
459+
}
458460
self.fetch_build_data_if_needed();
459461

460462
let loop_duration = loop_start.elapsed();
@@ -494,7 +496,10 @@ impl GlobalState {
494496
}
495497

496498
RequestDispatcher { req: Some(req), global_state: self }
497-
.on_sync::<lsp_ext::ReloadWorkspace>(|s, ()| Ok(s.fetch_workspaces_request()))?
499+
.on_sync::<lsp_ext::ReloadWorkspace>(|s, ()| {
500+
self.fetch_workspaces_request();
501+
self.fetch_workspaces_if_needed();
502+
})?
498503
.on_sync::<lsp_ext::JoinLines>(|s, p| handlers::handle_join_lines(s.snapshot(), p))?
499504
.on_sync::<lsp_ext::OnEnter>(|s, p| handlers::handle_on_enter(s.snapshot(), p))?
500505
.on_sync::<lsp_types::request::Shutdown>(|s, ()| {

crates/rust-analyzer/src/reload.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ impl GlobalState {
6060
", "
6161
)
6262
);
63-
if self.config.cargo_autoreload() {
64-
self.fetch_workspaces_request();
65-
} else {
66-
self.transition(Status::NeedsReload);
67-
}
63+
self.fetch_workspaces_request();
6864

6965
fn is_interesting(path: &AbsPath, change_kind: ChangeKind) -> bool {
7066
const IMPLICIT_TARGET_FILES: &[&str] = &["build.rs", "src/main.rs", "src/lib.rs"];

0 commit comments

Comments
 (0)