aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/main_loop.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-04-06 11:23:09 +0100
committerAleksey Kladov <[email protected]>2021-04-06 11:23:09 +0100
commit9143e3925cd95d30af72745f25e185f65a686d32 (patch)
tree701fd1902cce7792bf52b51772eadc44f4f8b673 /crates/rust-analyzer/src/main_loop.rs
parente3c47ccefca2069da70a9513bc2b7f6fbd0f894c (diff)
Prepare for more stateless status reporting
Diffstat (limited to 'crates/rust-analyzer/src/main_loop.rs')
-rw-r--r--crates/rust-analyzer/src/main_loop.rs43
1 files changed, 18 insertions, 25 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 7e96f3c4a..4a4705e1f 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -314,31 +314,23 @@ impl GlobalState {
314 } 314 }
315 } 315 }
316 vfs::loader::Message::Progress { n_total, n_done, config_version } => { 316 vfs::loader::Message::Progress { n_total, n_done, config_version } => {
317 self.vfs_progress_n_total = n_total;
318 self.vfs_progress_n_done = n_done;
317 always!(config_version <= self.vfs_config_version); 319 always!(config_version <= self.vfs_config_version);
318 if n_total == 0 { 320 let state = if n_done == 0 {
319 new_status = Status::Invalid; 321 Progress::Begin
322 } else if n_done < n_total {
323 Progress::Report
320 } else { 324 } else {
321 let state = if n_done == 0 { 325 assert_eq!(n_done, n_total);
322 new_status = Status::Loading; 326 Progress::End
323 Progress::Begin 327 };
324 } else if n_done < n_total { 328 self.report_progress(
325 Progress::Report 329 "roots scanned",
326 } else { 330 state,
327 assert_eq!(n_done, n_total); 331 Some(format!("{}/{}", n_done, n_total)),
328 new_status = Status::Ready { 332 Some(Progress::fraction(n_done, n_total)),
329 partial: self.config.run_build_scripts() 333 )
330 && self.workspace_build_data.is_none()
331 || config_version < self.vfs_config_version,
332 };
333 Progress::End
334 };
335 self.report_progress(
336 "roots scanned",
337 state,
338 Some(format!("{}/{}", n_done, n_total)),
339 Some(Progress::fraction(n_done, n_total)),
340 )
341 }
342 } 334 }
343 } 335 }
344 // Coalesce many VFS event into a single loop turn 336 // Coalesce many VFS event into a single loop turn
@@ -497,8 +489,9 @@ impl GlobalState {
497 489
498 RequestDispatcher { req: Some(req), global_state: self } 490 RequestDispatcher { req: Some(req), global_state: self }
499 .on_sync::<lsp_ext::ReloadWorkspace>(|s, ()| { 491 .on_sync::<lsp_ext::ReloadWorkspace>(|s, ()| {
500 self.fetch_workspaces_request(); 492 s.fetch_workspaces_request();
501 self.fetch_workspaces_if_needed(); 493 s.fetch_workspaces_if_needed();
494 Ok(())
502 })? 495 })?
503 .on_sync::<lsp_ext::JoinLines>(|s, p| handlers::handle_join_lines(s.snapshot(), p))? 496 .on_sync::<lsp_ext::JoinLines>(|s, p| handlers::handle_join_lines(s.snapshot(), p))?
504 .on_sync::<lsp_ext::OnEnter>(|s, p| handlers::handle_on_enter(s.snapshot(), p))? 497 .on_sync::<lsp_ext::OnEnter>(|s, p| handlers::handle_on_enter(s.snapshot(), p))?