Skip to content

Commit 6c8d33b

Browse files
committed
fix: make reload workspace work with disabled auto cargo config reload
1 parent d7acc83 commit 6c8d33b

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

crates/rust-analyzer/src/global_state.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ impl GlobalState {
346346
&path,
347347
file.kind(),
348348
&additional_files,
349+
&self.config,
349350
) {
350351
trace!(?path, kind = ?file.kind(), "refreshing for a change");
351352
workspace_structure_change.get_or_insert((path.clone(), false));

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,12 @@ pub(crate) fn handle_did_save_text_document(
177177

178178
// FIXME: We should move this check into a QueuedTask and do semantic resolution of
179179
// the files. There is only so much we can tell syntactically from the path.
180-
if reload::should_refresh_for_change(path, ChangeKind::Modify, additional_files) {
180+
if reload::should_refresh_for_change(
181+
path,
182+
ChangeKind::Modify,
183+
additional_files,
184+
&state.config,
185+
) {
181186
state.fetch_workspaces_queue.request_op(
182187
format!("workspace vfs file change saved {path}"),
183188
FetchWorkspaceRequest {

crates/rust-analyzer/src/main_loop.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -491,14 +491,10 @@ impl GlobalState {
491491
}
492492
}
493493

494-
if self.config.cargo_autoreload_config(None)
495-
|| self.config.discover_workspace_config().is_some()
494+
if let Some((cause, FetchWorkspaceRequest { path, force_crate_graph_reload })) =
495+
self.fetch_workspaces_queue.should_start_op()
496496
{
497-
if let Some((cause, FetchWorkspaceRequest { path, force_crate_graph_reload })) =
498-
self.fetch_workspaces_queue.should_start_op()
499-
{
500-
self.fetch_workspaces(cause, path, force_crate_graph_reload);
501-
}
497+
self.fetch_workspaces(cause, path, force_crate_graph_reload);
502498
}
503499

504500
if !self.fetch_workspaces_queue.op_in_progress() {

crates/rust-analyzer/src/reload.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,7 @@ pub(crate) fn should_refresh_for_change(
920920
path: &AbsPath,
921921
change_kind: ChangeKind,
922922
additional_paths: &[&str],
923+
config: &Config,
923924
) -> bool {
924925
const IMPLICIT_TARGET_FILES: &[&str] = &["build.rs", "src/main.rs", "src/lib.rs"];
925926
const IMPLICIT_TARGET_DIRS: &[&str] = &["src/bin", "examples", "tests", "benches"];
@@ -929,8 +930,10 @@ pub(crate) fn should_refresh_for_change(
929930
None => return false,
930931
};
931932

932-
if let "Cargo.toml" | "Cargo.lock" = file_name {
933-
return true;
933+
if config.cargo_autoreload_config(None) {
934+
if let "Cargo.toml" | "Cargo.lock" = file_name {
935+
return true;
936+
}
934937
}
935938

936939
if additional_paths.contains(&file_name) {

0 commit comments

Comments
 (0)