Unnamed repository; edit this file 'description' to name the repository.
feat: improve CPU usage
closes #9922
Turned out to be trivial after preliminary refactor.
The intended behavior is that we schedule cache priming once ws become
quiescent (that is, we fully load cargo project), and we continue to
rschedule it until it completes (priming might get cancelled by user
typing into a file).
| -rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 9f11254698..ad43e7eca0 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -296,12 +296,15 @@ impl GlobalState { )); fraction = Progress::fraction(report.n_done, report.n_total); } - PrimeCachesProgress::End { cancelled: _ } => { + PrimeCachesProgress::End { cancelled } => { state = Progress::End; message = None; fraction = 1.0; self.prime_caches_queue.op_completed(()); + if cancelled { + self.prime_caches_queue.request_op(); + } } }; @@ -424,11 +427,10 @@ impl GlobalState { for flycheck in &self.flycheck { flycheck.update(); } + self.prime_caches_queue.request_op(); } if !was_quiescent || state_changed { - self.prime_caches_queue.request_op(); - // Refresh semantic tokens if the client supports it. if self.config.semantic_tokens_refresh() { self.semantic_tokens_cache.lock().clear(); |