Don't re-read open files from disk when reloading a workspace

This commit is contained in:
Laurențiu Nicola 2020-09-18 22:15:44 +03:00
parent c217bc561f
commit 5a0bad7754

View 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(