Skip to content

Commit

Permalink
Don't try to suspend card if no note returned
Browse files Browse the repository at this point in the history
  • Loading branch information
glutanimate committed Mar 7, 2017
1 parent 5ea2745 commit 7b0a07b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cloze_overlapper/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,18 +328,18 @@ def myBurySiblings(self, card, _old):

def onAddNote(self, note, _old):
"""Suspend full cloze card if option active"""
oldret = _old(self, note)
if not checkModel(note.model(), fields=False, notify=False):
return oldret
note = _old(self, note)
if not note or not checkModel(note.model(), fields=False, notify=False):
return note
config = mw.col.conf["olcloze"]
sched_conf = config.get("sched", None)
if not sched_conf or not sched_conf[2]:
return oldret
return note
maxfields = ClozeOverlapper.getMaxFields(note.model(), config["flds"]["tx"])
last = note.cards()[-1]
if last.ord == maxfields: # is full cloze (ord starts at 0)
mw.col.sched.suspendCards([last.id])
return oldret
return note

# Menus

Expand Down

0 comments on commit 7b0a07b

Please sign in to comment.