Skip to content

Commit 5a0bad7

Browse files
committed
Don't re-read open files from disk when reloading a workspace
1 parent c217bc5 commit 5a0bad7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

crates/rust-analyzer/src/reload.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,14 @@ impl GlobalState {
201201
let mut crate_graph = CrateGraph::default();
202202
let vfs = &mut self.vfs.write().0;
203203
let loader = &mut self.loader;
204+
let mem_docs = &self.mem_docs;
204205
let mut load = |path: &AbsPath| {
205-
let contents = loader.handle.load_sync(path);
206-
let path = vfs::VfsPath::from(path.to_path_buf());
207-
vfs.set_file_contents(path.clone(), contents);
208-
vfs.file_id(&path)
206+
let vfs_path = vfs::VfsPath::from(path.to_path_buf());
207+
if !mem_docs.contains_key(&vfs_path) {
208+
let contents = loader.handle.load_sync(path);
209+
vfs.set_file_contents(vfs_path.clone(), contents);
210+
}
211+
vfs.file_id(&vfs_path)
209212
};
210213
for ws in workspaces.iter() {
211214
crate_graph.extend(ws.to_crate_graph(

0 commit comments

Comments
 (0)