Skip to content
This repository
Browse code

Fix one autoblanking bug

  • Loading branch information...
commit 141116a78c1b5051780722475028b1acedb10024 1 parent 70ad3f1
Max Bolingbroke authored February 11, 2010

Showing 1 changed file with 4 additions and 1 deletion. Show diff stats Hide diff stats

  1. 5  pinyin/anki/hooks.py
5  pinyin/anki/hooks.py
@@ -95,7 +95,10 @@ def onFocusLost(self, fact, field):
95 95
         # Changed fields have their "generated" tag stripped. NB: ALWAYS update the fact (even if the
96 96
         # field hasn't changed) because we might have changed ANOTHER field to e.g. blank it, and now
97 97
         # by moving focus from the expression field we indicate that we want to fill it out.
98  
-        self.updatefact(fact, field.name, fieldchanged and pinyin.factproxy.unmarkgeneratedfield(field.value) or None)
  98
+        #
  99
+        # NB: be careful with this ternary statement! It's perfectly OK for field.value to be "", and if
  100
+        # that happens we CAN'T let fieldvalue in updatefact be None, or autoblanking gets broken.
  101
+        self.updatefact(fact, field.name, (fieldchanged and [pinyin.factproxy.unmarkgeneratedfield(field.value)] or [None])[0])
99 102
     
100 103
     def updatefact(self, fact, fieldname, fieldvalue):
101 104
         # Are we not in a Mandarin model?

0 notes on commit 141116a

Please sign in to comment.
Something went wrong with that request. Please try again.