Fix/ignore revlogs when there is not learn entry after the last forget entry (#3199)

This commit is contained in:
Jarrett Ye 2024-05-17 13:07:15 +08:00 committed by GitHub
parent 70996146d2
commit 2b890b0eee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -239,15 +239,20 @@ pub(crate) fn single_card_revlog_to_items(
revlogs_complete = true;
} else if first_of_last_learn_entries.is_some() {
break;
// if we find the `Forget` entry before the `Learn` entry, we should
// ignore all the entries
} else if matches!(
(entry.review_kind, entry.ease_factor),
(RevlogReviewKind::Manual, 0)
) && first_of_last_learn_entries.is_none()
{
revlogs_complete = false;
break;
) {
// If we find a `Learn` entry after the `Forget` entry, we should
// ignore the entries before the `Forget` entry
if first_of_last_learn_entries.is_some() {
revlogs_complete = false;
break;
// If we don't find a `Learn` entry after the `Forget` entry, it's
// a new card and we should ignore all entries
} else {
return None;
}
}
}
if !revlogs_complete {