Skip to content

Commit 6da651f

Browse files
Don't prime caches when just opening a file
1 parent a3043cf commit 6da651f

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

crates/rust-analyzer/src/main_loop.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ impl GlobalState {
506506
.write()
507507
.0
508508
.set_file_contents(path, Some(params.text_document.text.into_bytes()));
509-
this.update_file_notifications_on_threadpool();
509+
this.maybe_update_diagnostics();
510510
}
511511
Ok(())
512512
})?
@@ -616,6 +616,23 @@ impl GlobalState {
616616
Ok(())
617617
}
618618
fn update_file_notifications_on_threadpool(&mut self) {
619+
self.maybe_update_diagnostics();
620+
self.task_pool.handle.spawn_with_sender({
621+
let snap = self.snapshot();
622+
move |sender| {
623+
snap.analysis
624+
.prime_caches(|progress| {
625+
sender.send(Task::PrimeCaches(progress)).unwrap();
626+
})
627+
.unwrap_or_else(|_: Canceled| {
628+
// Pretend that we're done, so that the progress bar is removed. Otherwise
629+
// the editor may complain about it already existing.
630+
sender.send(Task::PrimeCaches(PrimeCachesProgress::Finished)).unwrap()
631+
});
632+
}
633+
});
634+
}
635+
fn maybe_update_diagnostics(&mut self) {
619636
let subscriptions = self
620637
.mem_docs
621638
.keys()
@@ -644,19 +661,5 @@ impl GlobalState {
644661
Task::Diagnostics(diagnostics)
645662
})
646663
}
647-
self.task_pool.handle.spawn_with_sender({
648-
let snap = self.snapshot();
649-
move |sender| {
650-
snap.analysis
651-
.prime_caches(|progress| {
652-
sender.send(Task::PrimeCaches(progress)).unwrap();
653-
})
654-
.unwrap_or_else(|_: Canceled| {
655-
// Pretend that we're done, so that the progress bar is removed. Otherwise
656-
// the editor may complain about it already existing.
657-
sender.send(Task::PrimeCaches(PrimeCachesProgress::Finished)).unwrap()
658-
});
659-
}
660-
});
661664
}
662665
}

0 commit comments

Comments
 (0)