Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions crates/rust-analyzer/src/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ impl GlobalState {
.write()
.0
.set_file_contents(path, Some(params.text_document.text.into_bytes()));
this.update_file_notifications_on_threadpool();
this.maybe_update_diagnostics();
}
Ok(())
})?
Expand Down Expand Up @@ -616,6 +616,23 @@ impl GlobalState {
Ok(())
}
fn update_file_notifications_on_threadpool(&mut self) {
self.maybe_update_diagnostics();
self.task_pool.handle.spawn_with_sender({
let snap = self.snapshot();
move |sender| {
snap.analysis
.prime_caches(|progress| {
sender.send(Task::PrimeCaches(progress)).unwrap();
})
.unwrap_or_else(|_: Canceled| {
// Pretend that we're done, so that the progress bar is removed. Otherwise
// the editor may complain about it already existing.
sender.send(Task::PrimeCaches(PrimeCachesProgress::Finished)).unwrap()
});
}
});
}
fn maybe_update_diagnostics(&mut self) {
let subscriptions = self
.mem_docs
.keys()
Expand Down Expand Up @@ -644,19 +661,5 @@ impl GlobalState {
Task::Diagnostics(diagnostics)
})
}
self.task_pool.handle.spawn_with_sender({
let snap = self.snapshot();
move |sender| {
snap.analysis
.prime_caches(|progress| {
sender.send(Task::PrimeCaches(progress)).unwrap();
})
.unwrap_or_else(|_: Canceled| {
// Pretend that we're done, so that the progress bar is removed. Otherwise
// the editor may complain about it already existing.
sender.send(Task::PrimeCaches(PrimeCachesProgress::Finished)).unwrap()
});
}
});
}
}