Skip to content

Commit

Permalink
drop potentially slow regex usage in cloze check
Browse files Browse the repository at this point in the history
Closes #956, thanks to Henrik.
  • Loading branch information
dae committed Jan 30, 2021
1 parent 2199ca8 commit 9e5dc3f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion qt/aqt/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import aqt
import aqt.sound
from anki.cards import Card
from anki.consts import MODEL_CLOZE
from anki.hooks import runFilter
from anki.httpclient import HttpClient
from anki.notes import Note
Expand Down Expand Up @@ -655,7 +656,7 @@ def onCloze(self):

def _onCloze(self):
# check that the model is set up for cloze deletion
if not re.search("{{(.*:)*cloze:", self.note.model()["tmpls"][0]["qfmt"]):
if self.note.model()["type"] != MODEL_CLOZE:
if self.addMode:
tooltip(tr(TR.EDITING_WARNING_CLOZE_DELETIONS_WILL_NOT_WORK))
else:
Expand Down

0 comments on commit 9e5dc3f

Please sign in to comment.