Fix tests part 2...

This commit is contained in:
Steffen Lyngbaek 2020-03-15 23:32:28 -07:00
parent 70ccda3941
commit b6dec2eb1f

View File

@ -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,49 +710,49 @@ 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() {
let work_done_progress_create = request_new::<req::WorkDoneProgressCreate>(
loop_state.next_request_id(),
WorkDoneProgressCreateParams {
token: req::ProgressToken::String("rustAnalyzer/startup".into()),
},
);
sender.send(work_done_progress_create.into()).unwrap();
send_startup_progress_notif(
sender,
WorkDoneProgress::Begin(WorkDoneProgressBegin {
title: "rust-analyzer".into(),
cancellable: None,
message: Some(format!("{}/{} packages", progress, total)),
percentage: Some(100.0 * progress as f64 / total as f64),
}),
);
} else if progress < total {
send_startup_progress_notif(
match (prev_progress, loop_state.workspace_loaded) {
(None, false) => {
let work_done_progress_create = request_new::<req::WorkDoneProgressCreate>(
loop_state.next_request_id(),
WorkDoneProgressCreateParams {
token: req::ProgressToken::String("rustAnalyzer/startup".into()),
},
);
sender.send(work_done_progress_create.into()).unwrap();
send_startup_progress_notif(
sender,
WorkDoneProgress::Begin(WorkDoneProgressBegin {
title: "rust-analyzer".into(),
cancellable: None,
message: Some(format!("{}/{} packages", progress, total)),
percentage: Some(100.0 * progress as f64 / total as f64),
}),
);
}
(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)),
}),
)
),
_ => {}
}
}