Skip to content

Commit 4074803

Browse files
committed
add failing test
1 parent f253aa4 commit 4074803

File tree

1 file changed

+48
-0
lines changed
  • crates/rust-analyzer/src/config

1 file changed

+48
-0
lines changed

crates/rust-analyzer/src/config/tree.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,4 +609,52 @@ mod tests {
609609
let local = config_tree.local_config(crate_a);
610610
assert_eq!(local.completion_autoself_enable, true);
611611
}
612+
613+
#[test]
614+
fn no_change_to_source_roots() {
615+
tracing_subscriber::fmt().try_init().ok();
616+
let mut vfs = Vfs::default();
617+
618+
let project_root = AbsPath::assert(Path::new("/root"));
619+
let xdg =
620+
alloc_file_id(&mut vfs, "/home/username/.config/rust-analyzer/rust-analyzer.toml");
621+
let mut config_tree = ConfigDb::new(xdg, project_root.to_path_buf());
622+
623+
let source_roots = ["/root/crate_a"].map(Path::new).map(AbsPath::assert);
624+
let crate_a = vfs.alloc_file_id(source_roots[0].join("rust-analyzer.toml").into());
625+
626+
let _root = alloc_config(
627+
&mut vfs,
628+
"/root/rust-analyzer.toml",
629+
r#"
630+
[completion.autoself]
631+
enable = false
632+
"#,
633+
);
634+
635+
let new_source_roots = source_roots.into_iter().map(|abs| abs.to_path_buf()).collect();
636+
let changes = ConfigChanges {
637+
client_change: None,
638+
set_project_root: None, // already set in ConfigDb::new(...)
639+
set_source_roots: Some(new_source_roots),
640+
ra_toml_changes: dbg!(vfs.take_changes()),
641+
};
642+
config_tree.apply_changes(changes, &mut vfs);
643+
let local = config_tree.local_config(crate_a);
644+
// initially crate_a is part of the project root, so it does inherit
645+
// from /root/rust-analyzer.toml
646+
assert_eq!(local.completion_autoself_enable, false);
647+
648+
let changes = ConfigChanges {
649+
client_change: None,
650+
set_project_root: None,
651+
set_source_roots: None,
652+
ra_toml_changes: dbg!(vfs.take_changes()),
653+
};
654+
config_tree.apply_changes(changes, &mut vfs);
655+
let local = config_tree.local_config(crate_a);
656+
// initially crate_a is part of the project root, so it does inherit
657+
// from /root/rust-analyzer.toml
658+
assert_eq!(local.completion_autoself_enable, false);
659+
}
612660
}

0 commit comments

Comments
 (0)