diff options
author | Aleksey Kladov <[email protected]> | 2018-12-19 12:56:51 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-12-20 09:15:38 +0000 |
commit | 1b946ef8a61fa520459435d4e1cd674e0c550771 (patch) | |
tree | ab5d4ce1a3db81aba3db56579a00ca96a21bfa4a /crates/ra_vfs | |
parent | 7b6bafa631e6272946da568e9da7c3adc01ba625 (diff) |
File can be opened before the root is scanned
Diffstat (limited to 'crates/ra_vfs')
-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, |