aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-02 19:19:19 +0000
committerGitHub <[email protected]>2020-12-02 19:19:19 +0000
commitde9a984cbe33d270c0fab5478b429771b10ce0e4 (patch)
tree399803bc9b52eea44a4353fed4b10f705d150ed8
parenta3043cf53feffef3f69f25c2617801d2fc66ce75 (diff)
parent6da651f5dae29234516453b10f806cc4c8a319f1 (diff)
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 <[email protected]>
-rw-r--r--crates/rust-analyzer/src/main_loop.rs33
1 files changed, 18 insertions, 15 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index f349b0810..55d46b09e 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -506,7 +506,7 @@ impl GlobalState {
506 .write() 506 .write()
507 .0 507 .0
508 .set_file_contents(path, Some(params.text_document.text.into_bytes())); 508 .set_file_contents(path, Some(params.text_document.text.into_bytes()));
509 this.update_file_notifications_on_threadpool(); 509 this.maybe_update_diagnostics();
510 } 510 }
511 Ok(()) 511 Ok(())
512 })? 512 })?
@@ -616,6 +616,23 @@ impl GlobalState {
616 Ok(()) 616 Ok(())
617 } 617 }
618 fn update_file_notifications_on_threadpool(&mut self) { 618 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) {
619 let subscriptions = self 636 let subscriptions = self
620 .mem_docs 637 .mem_docs
621 .keys() 638 .keys()
@@ -644,19 +661,5 @@ impl GlobalState {
644 Task::Diagnostics(diagnostics) 661 Task::Diagnostics(diagnostics)
645 }) 662 })
646 } 663 }
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 });
661 } 664 }
662} 665}