First PR review changes

This commit is contained in:
mo8it
2024-10-10 19:43:35 +02:00
parent d3f819f86f
commit 685e069c58
5 changed files with 171 additions and 189 deletions
+10 -8
View File
@@ -157,8 +157,9 @@ impl<'a> WatchState<'a> {
/// Move on to the next exercise if the current one is done.
pub fn next_exercise(&mut self, stdout: &mut StdoutLock) -> Result<ExercisesProgress> {
if self.done_status == DoneStatus::Pending {
return Ok(ExercisesProgress::CurrentPending);
match self.done_status {
DoneStatus::DoneWithSolution(_) | DoneStatus::DoneWithoutSolution => (),
DoneStatus::Pending => return Ok(ExercisesProgress::CurrentPending),
}
self.app_state.done_current_exercise::<true>(stdout)
@@ -282,14 +283,15 @@ impl<'a> WatchState<'a> {
pub fn check_all_exercises(&mut self, stdout: &mut StdoutLock) -> Result<ExercisesProgress> {
stdout.write_all(b"\n")?;
if let Some(first_fail) = self.app_state.check_all_exercises(stdout, false)? {
// Only change exercise if the current one is done...
if let Some(first_pending_exercise_ind) = self.app_state.check_all_exercises(stdout)? {
// Only change exercise if the current one is done.
if self.app_state.current_exercise().done {
self.app_state.set_current_exercise_ind(first_fail)?;
self.app_state
.set_current_exercise_ind(first_pending_exercise_ind)?;
Ok(ExercisesProgress::NewPending)
} else {
Ok(ExercisesProgress::CurrentPending)
}
// ...but always pretend it's a "new" anyway because that refreshes
// the display
Ok(ExercisesProgress::NewPending)
} else {
self.app_state.render_final_message(stdout)?;
Ok(ExercisesProgress::AllDone)