@@ -426,12 +426,6 @@ fn loop_turn(
426
426
} ) ;
427
427
}
428
428
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
429
if !loop_state. workspace_loaded
436
430
&& world_state. roots_to_scan == 0
437
431
&& loop_state. pending_libraries . is_empty ( )
@@ -444,6 +438,9 @@ fn loop_turn(
444
438
let snap = world_state. snapshot ( ) ;
445
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
446
if state_changed {
@@ -713,49 +710,49 @@ fn send_startup_progress(
713
710
loop_state : & mut LoopState ,
714
711
world_state : & WorldState ,
715
712
) {
713
+ if !world_state. feature_flags . get ( "notifications.workspace-loaded" ) {
714
+ return ;
715
+ }
716
+
716
717
let total: usize = world_state. workspaces . iter ( ) . map ( |it| it. n_packages ( ) ) . sum ( ) ;
717
718
let prev_progress = loop_state. roots_scanned_progress ;
718
719
let progress = total - world_state. roots_to_scan ;
719
- if prev_progress == Some ( progress) {
720
- return ;
721
- }
722
720
loop_state. roots_scanned_progress = Some ( progress) ;
723
721
724
- if prev_progress. is_none ( ) {
725
- let work_done_progress_create = request_new :: < req:: WorkDoneProgressCreate > (
726
- loop_state. next_request_id ( ) ,
727
- WorkDoneProgressCreateParams {
728
- token : req:: ProgressToken :: String ( "rustAnalyzer/startup" . into ( ) ) ,
729
- } ,
730
- ) ;
731
- sender. send ( work_done_progress_create. into ( ) ) . unwrap ( ) ;
732
- send_startup_progress_notif (
733
- sender,
734
- WorkDoneProgress :: Begin ( WorkDoneProgressBegin {
735
- title : "rust-analyzer" . into ( ) ,
736
- cancellable : None ,
737
- message : Some ( format ! ( "{}/{} packages" , progress, total) ) ,
738
- percentage : Some ( 100.0 * progress as f64 / total as f64 ) ,
739
- } ) ,
740
- ) ;
741
- } else if progress < total {
742
- send_startup_progress_notif (
722
+ match ( prev_progress, loop_state. workspace_loaded ) {
723
+ ( None , false ) => {
724
+ let work_done_progress_create = request_new :: < req:: WorkDoneProgressCreate > (
725
+ loop_state. next_request_id ( ) ,
726
+ WorkDoneProgressCreateParams {
727
+ token : req:: ProgressToken :: String ( "rustAnalyzer/startup" . into ( ) ) ,
728
+ } ,
729
+ ) ;
730
+ sender. send ( work_done_progress_create. into ( ) ) . unwrap ( ) ;
731
+ send_startup_progress_notif (
732
+ sender,
733
+ WorkDoneProgress :: Begin ( WorkDoneProgressBegin {
734
+ title : "rust-analyzer" . into ( ) ,
735
+ cancellable : None ,
736
+ message : Some ( format ! ( "{}/{} packages" , progress, total) ) ,
737
+ percentage : Some ( 100.0 * progress as f64 / total as f64 ) ,
738
+ } ) ,
739
+ ) ;
740
+ }
741
+ ( Some ( prev) , false ) if progress != prev => send_startup_progress_notif (
743
742
sender,
744
743
WorkDoneProgress :: Report ( WorkDoneProgressReport {
745
744
cancellable : None ,
746
745
message : Some ( format ! ( "{}/{} packages" , progress, total) ) ,
747
746
percentage : Some ( 100.0 * progress as f64 / total as f64 ) ,
748
747
} ) ,
749
- )
750
- }
751
-
752
- if progress == total {
753
- send_startup_progress_notif (
748
+ ) ,
749
+ ( _, true ) => send_startup_progress_notif (
754
750
sender,
755
751
WorkDoneProgress :: End ( WorkDoneProgressEnd {
756
752
message : Some ( format ! ( "rust-analyzer loaded, {} packages" , progress) ) ,
757
753
} ) ,
758
- )
754
+ ) ,
755
+ _ => { }
759
756
}
760
757
}
761
758
0 commit comments