mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Fix new limit being decremented unduly (#2447)
This commit is contained in:
parent
146bed12d9
commit
662dbbd4ca
2 changed files with 18 additions and 5 deletions
|
@ -155,11 +155,14 @@ impl RemainingLimits {
|
||||||
/// True if some limit was decremented to 0.
|
/// True if some limit was decremented to 0.
|
||||||
fn decrement(&mut self, kind: LimitKind) -> DecrementResult {
|
fn decrement(&mut self, kind: LimitKind) -> DecrementResult {
|
||||||
let before = *self;
|
let before = *self;
|
||||||
if matches!(kind, LimitKind::Review) {
|
match kind {
|
||||||
self.review = self.review.saturating_sub(1);
|
LimitKind::Review => {
|
||||||
}
|
self.review = self.review.saturating_sub(1);
|
||||||
if self.cap_new_to_review || matches!(kind, LimitKind::New) {
|
if self.cap_new_to_review {
|
||||||
self.new = self.new.saturating_sub(1);
|
self.new = self.new.min(self.review);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LimitKind::New => self.new = self.new.saturating_sub(1),
|
||||||
}
|
}
|
||||||
DecrementResult::new(&before, self)
|
DecrementResult::new(&before, self)
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,4 +490,14 @@ mod test {
|
||||||
// review limit doesn't apply to new card
|
// review limit doesn't apply to new card
|
||||||
assert_eq!(col.card_queue_len(), 1);
|
assert_eq!(col.card_queue_len(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn reviews_dont_affect_new_limit_before_review_limit_is_reached() {
|
||||||
|
let mut col = Collection::new_v3();
|
||||||
|
col.update_default_deck_config(|config| {
|
||||||
|
config.new_per_day = 1;
|
||||||
|
});
|
||||||
|
CardAdder::new().siblings(2).due_dates(["0"]).add(&mut col);
|
||||||
|
assert_eq!(col.card_queue_len(), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue