don't allow {{c0::

This commit is contained in:
Damien Elmes 2012-05-06 18:08:15 +09:00
parent c1ea82273b
commit aedf88ee6d
2 changed files with 6 additions and 0 deletions

View file

@ -533,6 +533,8 @@ select id from notes where mid = ?)""" % " ".join(map),
ord = map[fname][0] ord = map[fname][0]
ords.update([int(m)-1 for m in re.findall( ords.update([int(m)-1 for m in re.findall(
"{{c(\d+)::[^}]*?}}", sflds[ord])]) "{{c(\d+)::[^}]*?}}", sflds[ord])])
if -1 in ords:
ords.remove(-1)
return list(ords) return list(ords)
# Sync handling # Sync handling

View file

@ -157,6 +157,10 @@ def test_cloze():
f['Text'] = "{{c2::hello}} {{c1::foo}}" f['Text'] = "{{c2::hello}} {{c1::foo}}"
f.flush() f.flush()
assert d.cardCount() == cnt + 1 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(): def test_modelChange():
deck = getEmptyDeck() deck = getEmptyDeck()