summaryrefslogtreecommitdiff
path: root/src/watch/state.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-10-10 19:43:35 +0200
committermo8it <mo8it@proton.me>2024-10-10 19:43:35 +0200
commit685e069c58ef02dae65381974722315ee8c84e8b (patch)
treec2a319c398fb7226b4109b81bdb00f419c689435 /src/watch/state.rs
parentd3f819f86f0fd7e67e9b995034947a65961cab34 (diff)
First PR review changes
Diffstat (limited to 'src/watch/state.rs')
-rw-r--r--src/watch/state.rs18
1 files changed, 10 insertions, 8 deletions
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<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)