From ccc75675b618f2ae59c77ee20064e613e74492bb Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Sep 2018 11:19:19 +0300 Subject: [PATCH] correctly setup path-map for fs-changes --- crates/server/src/server_world.rs | 47 ++++++++++++++++--------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/crates/server/src/server_world.rs b/crates/server/src/server_world.rs index ffa0e74b83..6853efc00c 100644 --- a/crates/server/src/server_world.rs +++ b/crates/server/src/server_world.rs @@ -39,30 +39,31 @@ impl ServerWorldState { mem_map: HashMap::new(), } } - pub fn apply_fs_changes(&mut self, events: Vec) { - let pm = &mut self.path_map; - let mm = &mut self.mem_map; - let changes = events.into_iter() - .map(|event| { - let text = match event.kind { - FileEventKind::Add(text) => Some(text), - }; - (event.path, text) - }) - .map(|(path, text)| { - (pm.get_or_insert(path, Root::Workspace), text) - }) - .filter_map(|(id, text)| { - if mm.contains_key(&id) { - mm.insert(id, text); - None - } else { - Some((id, text)) - } - }); - - self.analysis_host.change_files(changes); + { + let pm = &mut self.path_map; + let mm = &mut self.mem_map; + let changes = events.into_iter() + .map(|event| { + let text = match event.kind { + FileEventKind::Add(text) => Some(text), + }; + (event.path, text) + }) + .map(|(path, text)| { + (pm.get_or_insert(path, Root::Workspace), text) + }) + .filter_map(|(id, text)| { + if mm.contains_key(&id) { + mm.insert(id, text); + None + } else { + Some((id, text)) + } + }); + self.analysis_host.change_files(changes); + } + self.analysis_host.set_file_resolver(Arc::new(self.path_map.clone())); } pub fn events_to_files(&mut self, events: Vec) -> (Vec<(FileId, String)>, Arc) { let files = {