diff --git a/anki/models.py b/anki/models.py index 034a9f01f..0b5d159b1 100644 --- a/anki/models.py +++ b/anki/models.py @@ -533,6 +533,8 @@ select id from notes where mid = ?)""" % " ".join(map), ord = map[fname][0] ords.update([int(m)-1 for m in re.findall( "{{c(\d+)::[^}]*?}}", sflds[ord])]) + if -1 in ords: + ords.remove(-1) return list(ords) # Sync handling diff --git a/tests/test_models.py b/tests/test_models.py index 01e69c13d..fde8644c7 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -157,6 +157,10 @@ def test_cloze(): f['Text'] = "{{c2::hello}} {{c1::foo}}" f.flush() assert d.cardCount() == cnt + 1 + # 0 or negative indices are not supported + f['Text'] += "{{c0::zero}} {{c-1:foo}}" + f.flush() + assert len(f.cards()) == 2 def test_modelChange(): deck = getEmptyDeck()