From 5a0bad77543f9bf6df84e6c96b903683f8d23a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Fri, 18 Sep 2020 22:15:44 +0300 Subject: [PATCH] Don't re-read open files from disk when reloading a workspace --- crates/rust-analyzer/src/reload.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index b819618cb4..ae404331d9 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -201,11 +201,14 @@ impl GlobalState { let mut crate_graph = CrateGraph::default(); let vfs = &mut self.vfs.write().0; let loader = &mut self.loader; + let mem_docs = &self.mem_docs; let mut load = |path: &AbsPath| { - let contents = loader.handle.load_sync(path); - let path = vfs::VfsPath::from(path.to_path_buf()); - vfs.set_file_contents(path.clone(), contents); - vfs.file_id(&path) + let vfs_path = vfs::VfsPath::from(path.to_path_buf()); + if !mem_docs.contains_key(&vfs_path) { + let contents = loader.handle.load_sync(path); + vfs.set_file_contents(vfs_path.clone(), contents); + } + vfs.file_id(&vfs_path) }; for ws in workspaces.iter() { crate_graph.extend(ws.to_crate_graph(