diff --git a/pylib/anki/collection.py b/pylib/anki/collection.py index 58a22ed36..f187be88e 100644 --- a/pylib/anki/collection.py +++ b/pylib/anki/collection.py @@ -538,10 +538,12 @@ table.review-log {{ {revlog_style} }} # Undo ########################################################################## + # this data structure is a mess, and will be updated soon + # in the review case, [1, "Review", [firstReviewedCard, secondReviewedCard, ...], wasLeech] + # in the checkpoint case, [2, "action name"] + # wasLeech should have been recorded for each card, not globally def clearUndo(self) -> None: - # [type, undoName, data] - # type 1 = review; type 2 = checkpoint self._undo = None def undoName(self) -> Any: @@ -577,11 +579,14 @@ table.review-log {{ {revlog_style} }} c.note().flush() # write old data c.flush() - # and delete revlog entry - last = self.db.scalar( - "select id from revlog where cid = ? " "order by id desc limit 1", c.id - ) - self.db.execute("delete from revlog where id = ?", last) + # and delete revlog entry if not previewing + conf = self.sched._cardConf(c) + previewing = conf["dyn"] and not conf["resched"] + if not previewing: + last = self.db.scalar( + "select id from revlog where cid = ? " "order by id desc limit 1", c.id + ) + self.db.execute("delete from revlog where id = ?", last) # restore any siblings self.db.execute( "update cards set queue=type,mod=?,usn=? where queue=-2 and nid=?", diff --git a/pylib/anki/schedv2.py b/pylib/anki/schedv2.py index e592b2a59..af5dd7a75 100644 --- a/pylib/anki/schedv2.py +++ b/pylib/anki/schedv2.py @@ -131,6 +131,8 @@ class Scheduler: if card.odue: card.odue = 0 + # note: when adding revlog entries in the future, make sure undo + # code deletes the entries def _answerCardPreview(self, card: Card, ease: int) -> None: assert 1 <= ease <= 2