mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 06:03:58 +00:00
Merge #672
672: dont overwrite memfies r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
05d0c493c9
2 changed files with 15 additions and 1 deletions
|
@ -264,8 +264,10 @@ impl Vfs {
|
||||||
self.pending_changes.push(change);
|
self.pending_changes.push(change);
|
||||||
}
|
}
|
||||||
TaskResult::AddSingleFile { root, path, text } => {
|
TaskResult::AddSingleFile { root, path, text } => {
|
||||||
|
if self.find_file(root, &path).is_none() {
|
||||||
self.do_add_file(root, path, text, false);
|
self.do_add_file(root, path, text, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
TaskResult::ChangeSingleFile { root, path, text } => {
|
TaskResult::ChangeSingleFile { root, path, text } => {
|
||||||
if let Some(file) = self.find_file(root, &path) {
|
if let Some(file) = self.find_file(root, &path) {
|
||||||
self.do_change_file(file, text, false);
|
self.do_change_file(file, text, false);
|
||||||
|
|
|
@ -165,6 +165,18 @@ fn test_vfs_works() -> std::io::Result<()> {
|
||||||
assert_eq!(path, "sub1/sub2/new1.rs")
|
assert_eq!(path, "sub1/sub2/new1.rs")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
{
|
||||||
|
vfs.add_file_overlay(&dir.path().join("a/memfile.rs"), "memfile".to_string());
|
||||||
|
assert_match!(
|
||||||
|
vfs.commit_changes().as_slice(),
|
||||||
|
[VfsChange::AddFile { text, .. }],
|
||||||
|
assert_eq!(text.as_str(), "memfile")
|
||||||
|
);
|
||||||
|
fs::write(&dir.path().join("a/memfile.rs"), "ignore me").unwrap();
|
||||||
|
process_tasks(&mut vfs, 1);
|
||||||
|
assert_match!(vfs.commit_changes().as_slice(), []);
|
||||||
|
}
|
||||||
|
|
||||||
// should be ignored
|
// should be ignored
|
||||||
fs::create_dir_all(dir.path().join("a/target")).unwrap();
|
fs::create_dir_all(dir.path().join("a/target")).unwrap();
|
||||||
fs::write(&dir.path().join("a/target/new.rs"), "ignore me").unwrap();
|
fs::write(&dir.path().join("a/target/new.rs"), "ignore me").unwrap();
|
||||||
|
|
Loading…
Reference in a new issue