diff options
Diffstat (limited to 'crates/ra_vfs')
-rw-r--r-- | crates/ra_vfs/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/ra_vfs/tests/vfs.rs | 12 |
2 files changed, 15 insertions, 1 deletions
diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs index d1b0222e7..70a13f765 100644 --- a/crates/ra_vfs/src/lib.rs +++ b/crates/ra_vfs/src/lib.rs | |||
@@ -264,7 +264,9 @@ impl Vfs { | |||
264 | self.pending_changes.push(change); | 264 | self.pending_changes.push(change); |
265 | } | 265 | } |
266 | TaskResult::AddSingleFile { root, path, text } => { | 266 | TaskResult::AddSingleFile { root, path, text } => { |
267 | self.do_add_file(root, path, text, false); | 267 | if self.find_file(root, &path).is_none() { |
268 | self.do_add_file(root, path, text, false); | ||
269 | } | ||
268 | } | 270 | } |
269 | TaskResult::ChangeSingleFile { root, path, text } => { | 271 | TaskResult::ChangeSingleFile { root, path, text } => { |
270 | if let Some(file) = self.find_file(root, &path) { | 272 | if let Some(file) = self.find_file(root, &path) { |
diff --git a/crates/ra_vfs/tests/vfs.rs b/crates/ra_vfs/tests/vfs.rs index 357e1c775..545e1dbdd 100644 --- a/crates/ra_vfs/tests/vfs.rs +++ b/crates/ra_vfs/tests/vfs.rs | |||
@@ -165,6 +165,18 @@ fn test_vfs_works() -> std::io::Result<()> { | |||
165 | assert_eq!(path, "sub1/sub2/new1.rs") | 165 | assert_eq!(path, "sub1/sub2/new1.rs") |
166 | ); | 166 | ); |
167 | 167 | ||
168 | { | ||
169 | vfs.add_file_overlay(&dir.path().join("a/memfile.rs"), "memfile".to_string()); | ||
170 | assert_match!( | ||
171 | vfs.commit_changes().as_slice(), | ||
172 | [VfsChange::AddFile { text, .. }], | ||
173 | assert_eq!(text.as_str(), "memfile") | ||
174 | ); | ||
175 | fs::write(&dir.path().join("a/memfile.rs"), "ignore me").unwrap(); | ||
176 | process_tasks(&mut vfs, 1); | ||
177 | assert_match!(vfs.commit_changes().as_slice(), []); | ||
178 | } | ||
179 | |||
168 | // should be ignored | 180 | // should be ignored |
169 | fs::create_dir_all(dir.path().join("a/target")).unwrap(); | 181 | fs::create_dir_all(dir.path().join("a/target")).unwrap(); |
170 | fs::write(&dir.path().join("a/target/new.rs"), "ignore me").unwrap(); | 182 | fs::write(&dir.path().join("a/target/new.rs"), "ignore me").unwrap(); |