fix(watch): make sure watch doesn't skip not passing exercises if you change a previous one

This commit is contained in:
Koza 2022-08-30 14:25:01 +02:00
parent 3309a01b5e
commit 244fc903cd

View File

@ -373,10 +373,20 @@ fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<WatchStatus> {
.into_iter()
.chain(
exercises
.iter()
.filter(|e| !e.looks_done() && !filepath.ends_with(&e.path)),
.into_iter()
.take_while(|e| !filepath.ends_with(&e.path))
.filter(|e| !e.looks_done()),
)
.chain(
exercises
.into_iter()
.skip_while(|e| !filepath.ends_with(&e.path)),
);
let num_done = exercises.iter().filter(|e| e.looks_done()).count();
let num_done = exercises
.iter()
.take_while(|e| !filepath.ends_with(&e.path))
.filter(|e| e.looks_done())
.count();
clear_screen();
match verify(pending_exercises, (num_done, exercises.len()), verbose) {
Ok(_) => return Ok(WatchStatus::Finished),