Skip to content

Commit e3db4f3

Browse files
committed
Rely on the safer workspace_loaded check
1 parent 5a1e531 commit e3db4f3

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

crates/rust-analyzer/src/main_loop.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,12 @@ fn loop_turn(
426426
});
427427
}
428428

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+
429435
if !loop_state.workspace_loaded
430436
&& world_state.roots_to_scan == 0
431437
&& loop_state.pending_libraries.is_empty()
@@ -439,7 +445,6 @@ fn loop_turn(
439445
move || snap.analysis().prime_caches(subs).unwrap_or_else(|_: Canceled| ())
440446
});
441447
}
442-
send_startup_progress(&connection.sender, loop_state, world_state);
443448

444449
if state_changed {
445450
update_file_notifications_on_threadpool(
@@ -708,18 +713,15 @@ fn send_startup_progress(
708713
loop_state: &mut LoopState,
709714
world_state: &WorldState,
710715
) {
711-
if !world_state.feature_flags.get("notifications.workspace-loaded") {
712-
return;
713-
}
714716
let total: usize = world_state.workspaces.iter().map(|it| it.n_packages()).sum();
715717
let progress = total - world_state.roots_to_scan;
716718
if loop_state.roots_scanned_progress == Some(progress) {
717719
return;
718720
}
719721
loop_state.roots_scanned_progress = Some(progress);
720722

721-
match (progress, loop_state.workspace_loaded) {
722-
(0, false) => {
723+
match progress {
724+
0 => {
723725
let work_done_progress_create = request_new::<req::WorkDoneProgressCreate>(
724726
loop_state.next_request_id(),
725727
WorkDoneProgressCreateParams {
@@ -737,20 +739,20 @@ fn send_startup_progress(
737739
}),
738740
);
739741
}
740-
(_, false) => send_startup_progress_notif(
742+
progress if progress == total => send_startup_progress_notif(
743+
sender,
744+
WorkDoneProgress::End(WorkDoneProgressEnd {
745+
message: Some(format!("rust-analyzer loaded, {} packages", progress)),
746+
}),
747+
),
748+
progress => send_startup_progress_notif(
741749
sender,
742750
WorkDoneProgress::Report(WorkDoneProgressReport {
743751
cancellable: None,
744752
message: Some(format!("{}/{} packages", progress, total)),
745753
percentage: Some(100.0 * progress as f64 / total as f64),
746754
}),
747755
),
748-
(_, true) => send_startup_progress_notif(
749-
sender,
750-
WorkDoneProgress::End(WorkDoneProgressEnd {
751-
message: Some(format!("rust-analyzer loaded, {} packages", progress)),
752-
}),
753-
),
754756
}
755757
}
756758

0 commit comments

Comments
 (0)