diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 65 |
1 files changed, 31 insertions, 34 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 917dfad78..b410d3927 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -427,12 +427,6 @@ fn loop_turn( | |||
427 | } | 427 | } |
428 | 428 | ||
429 | if !loop_state.workspace_loaded | 429 | if !loop_state.workspace_loaded |
430 | && world_state.feature_flags.get("notifications.workspace-loaded") | ||
431 | { | ||
432 | send_startup_progress(&connection.sender, loop_state, world_state); | ||
433 | } | ||
434 | |||
435 | if !loop_state.workspace_loaded | ||
436 | && world_state.roots_to_scan == 0 | 430 | && world_state.roots_to_scan == 0 |
437 | && loop_state.pending_libraries.is_empty() | 431 | && loop_state.pending_libraries.is_empty() |
438 | && loop_state.in_flight_libraries == 0 | 432 | && loop_state.in_flight_libraries == 0 |
@@ -444,6 +438,9 @@ fn loop_turn( | |||
444 | let snap = world_state.snapshot(); | 438 | let snap = world_state.snapshot(); |
445 | move || snap.analysis().prime_caches(subs).unwrap_or_else(|_: Canceled| ()) | 439 | move || snap.analysis().prime_caches(subs).unwrap_or_else(|_: Canceled| ()) |
446 | }); | 440 | }); |
441 | send_startup_progress(&connection.sender, loop_state, world_state); | ||
442 | } else if !loop_state.workspace_loaded { | ||
443 | send_startup_progress(&connection.sender, loop_state, world_state); | ||
447 | } | 444 | } |
448 | 445 | ||
449 | if state_changed { | 446 | if state_changed { |
@@ -713,49 +710,49 @@ fn send_startup_progress( | |||
713 | loop_state: &mut LoopState, | 710 | loop_state: &mut LoopState, |
714 | world_state: &WorldState, | 711 | world_state: &WorldState, |
715 | ) { | 712 | ) { |
713 | if !world_state.feature_flags.get("notifications.workspace-loaded") { | ||
714 | return; | ||
715 | } | ||
716 | |||
716 | let total: usize = world_state.workspaces.iter().map(|it| it.n_packages()).sum(); | 717 | let total: usize = world_state.workspaces.iter().map(|it| it.n_packages()).sum(); |
717 | let prev_progress = loop_state.roots_scanned_progress; | 718 | let prev_progress = loop_state.roots_scanned_progress; |
718 | let progress = total - world_state.roots_to_scan; | 719 | let progress = total - world_state.roots_to_scan; |
719 | if prev_progress == Some(progress) { | ||
720 | return; | ||
721 | } | ||
722 | loop_state.roots_scanned_progress = Some(progress); | 720 | loop_state.roots_scanned_progress = Some(progress); |
723 | 721 | ||
724 | if prev_progress.is_none() { | 722 | match (prev_progress, loop_state.workspace_loaded) { |
725 | let work_done_progress_create = request_new::<req::WorkDoneProgressCreate>( | 723 | (None, false) => { |
726 | loop_state.next_request_id(), | 724 | let work_done_progress_create = request_new::<req::WorkDoneProgressCreate>( |
727 | WorkDoneProgressCreateParams { | 725 | loop_state.next_request_id(), |
728 | token: req::ProgressToken::String("rustAnalyzer/startup".into()), | 726 | WorkDoneProgressCreateParams { |
729 | }, | 727 | token: req::ProgressToken::String("rustAnalyzer/startup".into()), |
730 | ); | 728 | }, |
731 | sender.send(work_done_progress_create.into()).unwrap(); | 729 | ); |
732 | send_startup_progress_notif( | 730 | sender.send(work_done_progress_create.into()).unwrap(); |
733 | sender, | 731 | send_startup_progress_notif( |
734 | WorkDoneProgress::Begin(WorkDoneProgressBegin { | 732 | sender, |
735 | title: "rust-analyzer".into(), | 733 | WorkDoneProgress::Begin(WorkDoneProgressBegin { |
736 | cancellable: None, | 734 | title: "rust-analyzer".into(), |
737 | message: Some(format!("{}/{} packages", progress, total)), | 735 | cancellable: None, |
738 | percentage: Some(100.0 * progress as f64 / total as f64), | 736 | message: Some(format!("{}/{} packages", progress, total)), |
739 | }), | 737 | percentage: Some(100.0 * progress as f64 / total as f64), |
740 | ); | 738 | }), |
741 | } else if progress < total { | 739 | ); |
742 | send_startup_progress_notif( | 740 | } |
741 | (Some(prev), false) if progress != prev => send_startup_progress_notif( | ||
743 | sender, | 742 | sender, |
744 | WorkDoneProgress::Report(WorkDoneProgressReport { | 743 | WorkDoneProgress::Report(WorkDoneProgressReport { |
745 | cancellable: None, | 744 | cancellable: None, |
746 | message: Some(format!("{}/{} packages", progress, total)), | 745 | message: Some(format!("{}/{} packages", progress, total)), |
747 | percentage: Some(100.0 * progress as f64 / total as f64), | 746 | percentage: Some(100.0 * progress as f64 / total as f64), |
748 | }), | 747 | }), |
749 | ) | 748 | ), |
750 | } | 749 | (_, true) => send_startup_progress_notif( |
751 | |||
752 | if progress == total { | ||
753 | send_startup_progress_notif( | ||
754 | sender, | 750 | sender, |
755 | WorkDoneProgress::End(WorkDoneProgressEnd { | 751 | WorkDoneProgress::End(WorkDoneProgressEnd { |
756 | message: Some(format!("rust-analyzer loaded, {} packages", progress)), | 752 | message: Some(format!("rust-analyzer loaded, {} packages", progress)), |
757 | }), | 753 | }), |
758 | ) | 754 | ), |
755 | _ => {} | ||
759 | } | 756 | } |
760 | } | 757 | } |
761 | 758 | ||