From 86aafa74a67dd06390b2bb0f7cb6ae9503152414 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 7 Dec 2023 14:54:25 +1000 Subject: [PATCH] Treat cards with no reps like new cards https://github.com/open-spaced-repetition/fsrs4anki/issues/540#issuecomment-1837780217 --- rslib/src/scheduler/fsrs/memory_state.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rslib/src/scheduler/fsrs/memory_state.rs b/rslib/src/scheduler/fsrs/memory_state.rs index abdb78e8c..dfc3a65cf 100644 --- a/rslib/src/scheduler/fsrs/memory_state.rs +++ b/rslib/src/scheduler/fsrs/memory_state.rs @@ -166,7 +166,7 @@ impl Card { ) -> Result<()> { let memory_state = if let Some(i) = item { Some(fsrs.memory_state(i.item, i.starting_state)?) - } else if self.ctype == CardType::New || self.interval == 0 { + } else if self.ctype == CardType::New || self.interval == 0 || self.reps == 0 { None } else { // no valid revlog entries; infer state from current card state @@ -345,7 +345,10 @@ mod tests { difficulty: 4.46429 }) ); - let mut card = Card::default(); + let mut card = Card { + reps: 1, + ..Default::default() + }; card.set_memory_state(&fsrs, Some(item), 0.9)?; assert_eq!( card.memory_state, @@ -390,6 +393,7 @@ mod tests { ctype: CardType::Review, interval: 100, ease_factor: 1300, + reps: 1, ..Default::default() }; card.set_memory_state(&FSRS::new(Some(&[])).unwrap(), None, 0.9)?;