Skip to content

Commit 77e61f7

Browse files
committed
Better test for config tree
1 parent 851b970 commit 77e61f7

File tree

1 file changed

+18
-2
lines changed
  • crates/rust-analyzer/src/config

1 file changed

+18
-2
lines changed

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ impl ConfigTree {
292292
let node = self.tree.get_mut(node_id).ok_or(ConfigTreeError::NonExistent)?;
293293
node.get_mut().input = input;
294294

295+
// We won't do any funny business comparing the previous input to the new one, because
296+
// that would require implementing PartialEq on the dozens and dozens of types that make
297+
// up ConfigInput.
295298
self.invalidate_subtree(node_id);
296299
// tracing::trace!("invalidated subtree:\n{:#?}", node_id.debug_pretty_print(&self.tree));
297300
Ok(node_id)
@@ -495,6 +498,12 @@ mod tests {
495498
# default is "never"
496499
[inlayHints.discriminantHints]
497500
enable = "always"
501+
[completion.autoself]
502+
enable = true
503+
[completion.autoimport]
504+
enable = true
505+
[semanticHighlighting.strings]
506+
enable = true
498507
"#
499508
.to_string()
500509
.into_bytes(),
@@ -510,13 +519,20 @@ mod tests {
510519

511520
let prev = local;
512521
let local = config_tree.read_config(crate_a).unwrap();
522+
// Should have been recomputed
513523
assert!(!Arc::ptr_eq(&prev, &local));
514-
let local2 = config_tree.read_config(crate_a).unwrap();
515-
assert!(Arc::ptr_eq(&local, &local2));
524+
// But without changes in between, should give the same Arc back
525+
assert!(Arc::ptr_eq(&local, &config_tree.read_config(crate_a).unwrap()));
516526

527+
// The newly added xdg_config_file_id should affect the output if nothing else touches
528+
// this key
517529
assert_eq!(
518530
local.inlayHints_discriminantHints_enable,
519531
crate::config::DiscriminantHintsDef::Always
520532
);
533+
// But it should not win
534+
assert_eq!(local.completion_autoself_enable, false);
535+
assert_eq!(local.completion_autoimport_enable, false);
536+
assert_eq!(local.semanticHighlighting_strings_enable, false);
521537
}
522538
}

0 commit comments

Comments
 (0)