From 685e069c58ef02dae65381974722315ee8c84e8b Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 10 Oct 2024 19:43:35 +0200 Subject: First PR review changes --- src/watch/state.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/watch') diff --git a/src/watch/state.rs b/src/watch/state.rs index 67a6357..8b58e31 100644 --- a/src/watch/state.rs +++ b/src/watch/state.rs @@ -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 { - 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::(stdout) @@ -282,14 +283,15 @@ impl<'a> WatchState<'a> { pub fn check_all_exercises(&mut self, stdout: &mut StdoutLock) -> Result { 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) -- cgit v1.2.3