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(