Skip to content

Commit 1e0853e

Browse files
changes to Cargo config should always refresh
1 parent 664f305 commit 1e0853e

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

crates/rust-analyzer/src/reload.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,7 @@ pub(crate) fn should_refresh_for_change(
975975
change_kind: ChangeKind,
976976
additional_paths: &[&str],
977977
) -> bool {
978+
// Note: build scripts are retriggered on file save, no refresh is necessary
978979
const IMPLICIT_TARGET_FILES: &[&str] = &["build.rs", "src/main.rs", "src/lib.rs"];
979980
const IMPLICIT_TARGET_DIRS: &[&str] = &["src/bin", "examples", "tests", "benches"];
980981

@@ -991,15 +992,20 @@ pub(crate) fn should_refresh_for_change(
991992
return true;
992993
}
993994

995+
// .cargo/config{.toml}
996+
if matches!(file_name, "config.toml" | "config")
997+
&& path.parent().map(|parent| parent.as_str().ends_with(".cargo")).unwrap_or(false)
998+
{
999+
return true;
1000+
}
1001+
1002+
// Everything below only matters when files are created or deleted
9941003
if change_kind == ChangeKind::Modify {
9951004
return false;
9961005
}
9971006

998-
// .cargo/config{.toml}
9991007
if path.extension().unwrap_or_default() != "rs" {
1000-
let is_cargo_config = matches!(file_name, "config.toml" | "config")
1001-
&& path.parent().map(|parent| parent.as_str().ends_with(".cargo")).unwrap_or(false);
1002-
return is_cargo_config;
1008+
return false;
10031009
}
10041010

10051011
if IMPLICIT_TARGET_FILES.iter().any(|it| path.as_str().ends_with(it)) {

0 commit comments

Comments
 (0)