@@ -208,8 +208,8 @@ pub fn main_loop(
208208 )
209209 } ;
210210
211- loop_state. roots_to_scan = world_state. vfs . read ( ) . n_roots ( ) ;
212- loop_state. roots_total = loop_state . roots_to_scan ;
211+ loop_state. roots_total = world_state. vfs . read ( ) . n_roots ( ) ;
212+ loop_state. roots_scanned = 0 ;
213213
214214 let pool = ThreadPool :: default ( ) ;
215215 let ( task_sender, task_receiver) = unbounded :: < Task > ( ) ;
@@ -337,8 +337,8 @@ struct LoopState {
337337 pending_libraries : Vec < ( SourceRootId , Vec < ( FileId , RelativePathBuf , Arc < String > ) > ) > ,
338338 workspace_loaded : bool ,
339339
340- roots_scanned_progress : Option < usize > ,
341- roots_to_scan : usize ,
340+ roots_progress_reported : Option < usize > ,
341+ roots_scanned : usize ,
342342 roots_total : usize ,
343343}
344344
@@ -383,7 +383,7 @@ fn loop_turn(
383383 world_state. add_lib ( lib) ;
384384 world_state. maybe_collect_garbage ( ) ;
385385 loop_state. in_flight_libraries -= 1 ;
386- loop_state. roots_to_scan - = 1 ;
386+ loop_state. roots_scanned + = 1 ;
387387 }
388388 Event :: CheckWatcher ( task) => on_check_task ( task, world_state, task_sender) ?,
389389 Event :: Msg ( msg) => match msg {
@@ -415,7 +415,7 @@ fn loop_turn(
415415 } ;
416416
417417 let mut state_changed = false ;
418- if let Some ( changes) = world_state. process_changes ( & mut loop_state. roots_to_scan ) {
418+ if let Some ( changes) = world_state. process_changes ( & mut loop_state. roots_scanned ) {
419419 state_changed = true ;
420420 loop_state. pending_libraries . extend ( changes) ;
421421 }
@@ -438,7 +438,7 @@ fn loop_turn(
438438 && world_state. feature_flags . get ( "notifications.workspace-loaded" ) ;
439439
440440 if !loop_state. workspace_loaded
441- && loop_state. roots_to_scan == 0
441+ && loop_state. roots_scanned == loop_state . roots_total
442442 && loop_state. pending_libraries . is_empty ( )
443443 && loop_state. in_flight_libraries == 0
444444 {
@@ -719,11 +719,11 @@ fn on_diagnostic_task(task: DiagnosticTask, msg_sender: &Sender<Message>, state:
719719
720720fn send_startup_progress ( sender : & Sender < Message > , loop_state : & mut LoopState ) {
721721 let total: usize = loop_state. roots_total ;
722- let prev_progress = loop_state. roots_scanned_progress ;
723- let progress = total - loop_state. roots_to_scan ;
724- loop_state. roots_scanned_progress = Some ( progress) ;
722+ let prev = loop_state. roots_progress_reported ;
723+ let progress = loop_state. roots_scanned ;
724+ loop_state. roots_progress_reported = Some ( progress) ;
725725
726- match ( prev_progress , loop_state. workspace_loaded ) {
726+ match ( prev , loop_state. workspace_loaded ) {
727727 ( None , false ) => {
728728 let work_done_progress_create = request_new :: < req:: WorkDoneProgressCreate > (
729729 loop_state. next_request_id ( ) ,
0 commit comments