6036: Don't re-read open files from disk when reloading a workspace r=kjeremy a=lnicola

Fixes #5742
Fixes #4263

or so I hope.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
bors[bot] 2020-09-18 21:29:47 +00:00 committed by GitHub
commit fb1b0a4bff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -201,11 +201,14 @@ impl GlobalState {
let mut crate_graph = CrateGraph::default(); let mut crate_graph = CrateGraph::default();
let vfs = &mut self.vfs.write().0; let vfs = &mut self.vfs.write().0;
let loader = &mut self.loader; let loader = &mut self.loader;
let mem_docs = &self.mem_docs;
let mut load = |path: &AbsPath| { let mut load = |path: &AbsPath| {
let contents = loader.handle.load_sync(path); let vfs_path = vfs::VfsPath::from(path.to_path_buf());
let path = vfs::VfsPath::from(path.to_path_buf()); if !mem_docs.contains_key(&vfs_path) {
vfs.set_file_contents(path.clone(), contents); let contents = loader.handle.load_sync(path);
vfs.file_id(&path) vfs.set_file_contents(vfs_path.clone(), contents);
}
vfs.file_id(&vfs_path)
}; };
for ws in workspaces.iter() { for ws in workspaces.iter() {
crate_graph.extend(ws.to_crate_graph( crate_graph.extend(ws.to_crate_graph(