Bug Report: Ctrl + Z after adding Cloze deletes text inside the cloze card in Card Editor

How to recreate:

  1. First I highlight part of the text as normal that I want to be inside the cloze card so that I can use Ctrl + Shift + C

  2. If I were to undo the addition of the cloze card using Ctrl + Z, the cloze card is indeed remove, but it deletes the text that was inside it as well.

The bug occurs pretty often but sometimes it works as normal. (only removing the cloze card and not the text with it as well.

The Ctrl + Z reverses line breaks by pressing Enter just fine but if I have added a cloze card to the text it deletes every cloze card along with its text inside it until the next line break.

If I have no line breaks at all in the text, the entire text of the cloze note is completely deleted by just pressing Ctrl + Z, no matter how many cloze cards have been added.

If this is some issue that is caused primarily by my system and not through anki itself, please do let me know of a possible fix.

If this indeed is a bug, I hope for a fix in the next update.

I have downgraded back from 24.04.2 to 24.04 and the problem is fixed. The cause is definitely a bug in the latest release.

Thanks for the report.

@abdo, this is Preserve HTML formatting inside clozes by abdnh · Pull Request #3038 · ankitects/anki · GitHub. If we’re to keep this change, can we clear out the undo queue so that we at least don’t break things when the user attempts to undo? I’m wondering whether it might be better to just shelve this until we can implement our own undo queue however. What do you think?

1 Like

It doesn’t appear to be possible to clear the undo queue of document.execCommand(), so I think we have to defer it.

1 Like