diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 33 |
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 | } |