Skip to content

Commit 8177b17

Browse files
committed
Add a failing test for irrelevant vfs changes
1 parent bf1419a commit 8177b17

File tree

1 file changed

+28
-1
lines changed
  • crates/rust-analyzer/src/config

1 file changed

+28
-1
lines changed

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use vfs::{AbsPathBuf, FileId, Vfs};
55

66
use super::{ConfigInput, LocalConfigData, RootLocalConfigData};
77

8-
#[derive(Debug)]
8+
#[derive(Debug, PartialEq)]
99
pub enum ConfigTreeError {
1010
Removed,
1111
NonExistent,
@@ -654,4 +654,31 @@ mod tests {
654654
let local = config_tree.local_config(crate_a);
655655
assert_eq!(local.completion_autoself_enable, false);
656656
}
657+
658+
#[test]
659+
fn ignore_irrelevant_vfs_changes() {
660+
tracing_subscriber::fmt().try_init().ok();
661+
let mut vfs = Vfs::default();
662+
663+
let project_root = AbsPath::assert("/root");
664+
let xdg = alloc_file_id(&mut vfs, XDG_CONFIG_HOME_RATOML);
665+
let mut config_tree = ConfigDb::new(xdg, project_root.to_path_buf());
666+
667+
// The main way an irrelevant vfs file change is going to show up is in TOML parse errors.
668+
let invalid_utf8 = b"\xc3\x28";
669+
vfs.set_file_contents(
670+
AbsPath::assert("/irrelevant/file.bin").to_path_buf().into(),
671+
Some(invalid_utf8.to_vec()),
672+
);
673+
let errors = config_tree.apply_changes(
674+
ConfigChanges {
675+
client_change: None,
676+
set_project_root: None,
677+
set_source_roots: None,
678+
ra_toml_changes: vfs.take_changes(),
679+
},
680+
&mut vfs,
681+
);
682+
assert_eq!(errors, vec![]);
683+
}
657684
}

0 commit comments

Comments
 (0)