Fix new limit being decremented unduly (#2447)
This commit is contained in:
parent
146bed12d9
commit
662dbbd4ca
@ -155,11 +155,14 @@ impl RemainingLimits {
|
||||
/// True if some limit was decremented to 0.
|
||||
fn decrement(&mut self, kind: LimitKind) -> DecrementResult {
|
||||
let before = *self;
|
||||
if matches!(kind, LimitKind::Review) {
|
||||
self.review = self.review.saturating_sub(1);
|
||||
}
|
||||
if self.cap_new_to_review || matches!(kind, LimitKind::New) {
|
||||
self.new = self.new.saturating_sub(1);
|
||||
match kind {
|
||||
LimitKind::Review => {
|
||||
self.review = self.review.saturating_sub(1);
|
||||
if self.cap_new_to_review {
|
||||
self.new = self.new.min(self.review);
|
||||
}
|
||||
}
|
||||
LimitKind::New => self.new = self.new.saturating_sub(1),
|
||||
}
|
||||
DecrementResult::new(&before, self)
|
||||
}
|
||||
|
@ -490,4 +490,14 @@ mod test {
|
||||
// review limit doesn't apply to new card
|
||||
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 New Issue
Block a user