Fix broken tests
Handle case of no projects. The notification still needs to be posted
@@ -714,14 +714,14 @@ fn send_startup_progress(
world_state: &WorldState,
) {
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 loop_state.roots_scanned_progress == Some(progress) {
+ if prev_progress == Some(progress) {
return;
}
loop_state.roots_scanned_progress = Some(progress);
- match progress {
- 0 => {
+ if prev_progress.is_none() {
let work_done_progress_create = request_new::<req::WorkDoneProgressCreate>(
loop_state.next_request_id(),
WorkDoneProgressCreateParams {
@@ -738,21 +738,24 @@ fn send_startup_progress(
percentage: Some(100.0 * progress as f64 / total as f64),
}),
);
- }
- progress if progress == total => send_startup_progress_notif(
- sender,
- WorkDoneProgress::End(WorkDoneProgressEnd {
- message: Some(format!("rust-analyzer loaded, {} packages", progress)),
- }),
- ),
- progress => send_startup_progress_notif(
+ } else if progress < total {
+ 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(
+ sender,
+ WorkDoneProgress::End(WorkDoneProgressEnd {
+ message: Some(format!("rust-analyzer loaded, {} packages", progress)),
+ }),
+ )
}
}
