diff options
-rw-r--r-- | crates/ra_vfs/src/lib.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs index 3a68039f0..4de07b093 100644 --- a/crates/ra_vfs/src/lib.rs +++ b/crates/ra_vfs/src/lib.rs | |||
@@ -207,11 +207,23 @@ impl Vfs { | |||
207 | 207 | ||
208 | pub fn handle_task(&mut self, task: io::TaskResult) { | 208 | pub fn handle_task(&mut self, task: io::TaskResult) { |
209 | let mut files = Vec::new(); | 209 | let mut files = Vec::new(); |
210 | // While we were scanning the root in the backgound, a file might have | ||
211 | // been open in the editor, so we need to account for that. | ||
212 | let exising = self.root2files[&task.root] | ||
213 | .iter() | ||
214 | .map(|&file| (self.files[file].path.clone(), file)) | ||
215 | .collect::<FxHashMap<_, _>>(); | ||
210 | for (path, text) in task.files { | 216 | for (path, text) in task.files { |
217 | if let Some(&file) = exising.get(&path) { | ||
218 | let text = Arc::clone(&self.files[file].text); | ||
219 | files.push((file, path, text)); | ||
220 | continue; | ||
221 | } | ||
211 | let text = Arc::new(text); | 222 | let text = Arc::new(text); |
212 | let file = self.add_file(task.root, path.clone(), Arc::clone(&text)); | 223 | let file = self.add_file(task.root, path.clone(), Arc::clone(&text)); |
213 | files.push((file, path, text)); | 224 | files.push((file, path, text)); |
214 | } | 225 | } |
226 | |||
215 | let change = VfsChange::AddRoot { | 227 | let change = VfsChange::AddRoot { |
216 | root: task.root, | 228 | root: task.root, |
217 | files, | 229 | files, |