]> git.lizzy.rs Git - rust.git/commitdiff
Don't re-read open files from disk when reloading a workspace
authorLaurențiu Nicola <lnicola@dend.ro>
Fri, 18 Sep 2020 19:15:44 +0000 (22:15 +0300)
committerLaurențiu Nicola <lnicola@dend.ro>
Fri, 18 Sep 2020 19:15:44 +0000 (22:15 +0300)
crates/rust-analyzer/src/reload.rs

index b819618cb4dae13ac9ed14dcb9ab92f115677773..ae404331d94338a3a6baf098398fee4623349d0c 100644 (file)
@@ -201,11 +201,14 @@ pub(crate) fn switch_workspaces(&mut self, workspaces: Vec<anyhow::Result<Projec
             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(