drop potentially slow regex usage in cloze check

Closes #956, thanks to Henrik.
This commit is contained in:
Damien Elmes 2021-01-29 11:15:08 +10:00
parent f45d51c92d
commit 64af4dfe7e

View file

@ -21,6 +21,7 @@ from bs4 import BeautifulSoup
import aqt import aqt
import aqt.sound import aqt.sound
from anki.cards import Card from anki.cards import Card
from anki.consts import MODEL_CLOZE
from anki.hooks import runFilter from anki.hooks import runFilter
from anki.httpclient import HttpClient from anki.httpclient import HttpClient
from anki.notes import Note from anki.notes import Note
@ -675,7 +676,7 @@ class Editor:
def _onCloze(self): def _onCloze(self):
# check that the model is set up for cloze deletion # 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: if self.addMode:
tooltip(tr(TR.EDITING_WARNING_CLOZE_DELETIONS_WILL_NOT_WORK)) tooltip(tr(TR.EDITING_WARNING_CLOZE_DELETIONS_WILL_NOT_WORK))
else: else: