From 9e5dc3f6451759001363712fc14c53e82fb71675 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 29 Jan 2021 11:15:08 +1000 Subject: [PATCH] drop potentially slow regex usage in cloze check Closes #956, thanks to Henrik. --- qt/aqt/editor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index 79a1dde15..a3dcbed57 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -20,6 +20,7 @@ from bs4 import BeautifulSoup 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 @@ -655,7 +656,7 @@ class Editor: 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: