Skip to content

Commit 69f94d5

Browse files
committed
add note about Path::starts_with and another test where the source roots are changed
1 parent cbbfa37 commit 69f94d5

File tree

1 file changed

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

1 file changed

+26
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,5 +522,31 @@ mod tests {
522522
crate::config::DiscriminantHintsDef::Always
523523
);
524524
assert_eq!(local.completion_autoself_enable, false);
525+
526+
// ----
527+
528+
// Now move crate b to the root. This gives a new FileId for crate_b/ra.toml.
529+
let source_roots = ["/root/crate_a", "/root/crate_b"].map(Path::new).map(AbsPath::assert);
530+
let [crate_a, crate_b] = source_roots
531+
.map(|dir| dir.join("rust-analyzer.toml"))
532+
.map(|path| vfs.alloc_file_id(path.into()));
533+
let new_source_roots = source_roots.into_iter().map(|abs| abs.to_path_buf()).collect();
534+
let changes = ConfigChanges {
535+
client_change: None,
536+
set_project_root: None, // already set in ConfigDb::new(...)
537+
set_source_roots: Some(new_source_roots),
538+
ra_toml_changes: dbg!(vfs.take_changes()),
539+
};
540+
541+
dbg!(config_tree.apply_changes(changes, &mut vfs));
542+
let local = config_tree.local_config(crate_b);
543+
544+
// Still inherits from xdg
545+
assert_eq!(
546+
local.inlayHints_discriminantHints_enable,
547+
crate::config::DiscriminantHintsDef::Always
548+
);
549+
// new crate_b does not inherit from crate_a
550+
assert_eq!(local.completion_autoself_enable, true);
525551
}
526552
}

0 commit comments

Comments
 (0)