Merge #6701
6701: Don't prime caches when just opening a file r=jonas-schievink a=jonas-schievink Fixes occasional "progress handler already registered" errors. bors r+ Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
commit
de9a984cbe
@ -506,7 +506,7 @@ fn on_notification(&mut self, not: Notification) -> Result<()> {
|
||||
.write()
|
||||
.0
|
||||
.set_file_contents(path, Some(params.text_document.text.into_bytes()));
|
||||
this.update_file_notifications_on_threadpool();
|
||||
this.maybe_update_diagnostics();
|
||||
}
|
||||
Ok(())
|
||||
})?
|
||||
@ -616,6 +616,23 @@ fn on_notification(&mut self, not: Notification) -> Result<()> {
|
||||
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()
|
||||
@ -644,19 +661,5 @@ fn update_file_notifications_on_threadpool(&mut self) {
|
||||
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()
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user