diff --git a/.gitignore b/.gitignore index 207e246..a01f22f 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ __pycache__ chinese/config_saved.json chinese/meta.json Pipfile.lock +.vscode diff --git a/chinese/behavior.py b/chinese/behavior.py index 6ff2970..6219889 100644 --- a/chinese/behavior.py +++ b/chinese/behavior.py @@ -246,8 +246,10 @@ def fill_all_rubies(hanzi, note): def update_fields(note, focus_field, fields): copy = dict(note) hanzi = get_first(config['fields']['hanzi'], copy) - if not hanzi: + + if hanzi is None: # check if hanzi field exists return False + hanzi = cleanup(hanzi) transcript_fields = ( @@ -261,8 +263,8 @@ def update_fields(note, focus_field, fields): fill_color(hanzi, copy) fill_all_rubies(hanzi, copy) - if focus_field in config['fields']['hanzi']: - if copy[focus_field]: + if focus_field in config['fields']['hanzi']: #focus field is hanzi field + if copy[focus_field]: #hanzi field is not empty fill_all_defs(hanzi, copy) fill_classifier(hanzi, copy) fill_transcript(hanzi, copy) diff --git a/chinese/edit.py b/chinese/edit.py index b9c5e39..d95a510 100644 --- a/chinese/edit.py +++ b/chinese/edit.py @@ -72,10 +72,7 @@ def onFocusLost(self, _, note, index): field = allFields[index] if update_fields(note, field, allFields): - if index == len(allFields) - 1: - self.editor.loadNote(focusTo=index) - else: - self.editor.loadNote(focusTo=index+1) + self.editor.loadNote() return False diff --git a/chinese/util.py b/chinese/util.py index 61af6ce..ef68217 100644 --- a/chinese/util.py +++ b/chinese/util.py @@ -44,8 +44,7 @@ def all_fields_empty(note, fields): def erase_fields(note, fields): - for f in fields: - set_all(f, note, to='') + set_all(fields, note, to='') def get_first(fields, note):