Fix tests part 2...
@@ -426,12 +426,6 @@ fn loop_turn(
});
}
- if !loop_state.workspace_loaded
- && world_state.feature_flags.get("notifications.workspace-loaded")
- {
- send_startup_progress(&connection.sender, loop_state, world_state);
- }
-
if !loop_state.workspace_loaded
&& world_state.roots_to_scan == 0
&& loop_state.pending_libraries.is_empty()
@@ -444,6 +438,9 @@ fn loop_turn(
let snap = world_state.snapshot();
move || snap.analysis().prime_caches(subs).unwrap_or_else(|_: Canceled| ())
});
+ send_startup_progress(&connection.sender, loop_state, world_state);
+ } else if !loop_state.workspace_loaded {
+ send_startup_progress(&connection.sender, loop_state, world_state);
}
if state_changed {
@@ -713,15 +710,17 @@ fn send_startup_progress(
loop_state: &mut LoopState,
world_state: &WorldState,
) {
+ if !world_state.feature_flags.get("notifications.workspace-loaded") {
+ return;
+ }
+
let total: usize = world_state.workspaces.iter().map(|it| it.n_packages()).sum();
let prev_progress = loop_state.roots_scanned_progress;
let progress = total - world_state.roots_to_scan;
- if prev_progress == Some(progress) {
- return;
- }
loop_state.roots_scanned_progress = Some(progress);
- if prev_progress.is_none() {
+ match (prev_progress, loop_state.workspace_loaded) {
+ (None, false) => {
let work_done_progress_create = request_new::<req::WorkDoneProgressCreate>(
loop_state.next_request_id(),
WorkDoneProgressCreateParams {
@@ -738,24 +737,22 @@ fn send_startup_progress(
percentage: Some(100.0 * progress as f64 / total as f64),
}),
);
- } else if progress < total {
- send_startup_progress_notif(
+ }
+ (Some(prev), false) if progress != prev => send_startup_progress_notif(
sender,
WorkDoneProgress::Report(WorkDoneProgressReport {
cancellable: None,
message: Some(format!("{}/{} packages", progress, total)),
percentage: Some(100.0 * progress as f64 / total as f64),
}),
- )
- }
-
- if progress == total {
- send_startup_progress_notif(
+ ),
+ (_, true) => send_startup_progress_notif(
sender,
WorkDoneProgress::End(WorkDoneProgressEnd {
message: Some(format!("rust-analyzer loaded, {} packages", progress)),
}),
- )
+ ),
+ _ => {}
}
}
