Permalink
Browse files

Fixed not-initialised bug with NO tags in notes

If there were no tags whatsoever in the full list of notes, then the
TriggeredcompleteEntry completion list would not get set, resulting in
tracebacks during execution.
  • Loading branch information...
cpbotha committed Dec 4, 2012
1 parent 350db3b commit 166e0bd4eaaae36a20556e72969400b3976c2187
Showing with 16 additions and 5 deletions.
  1. +16 −5 nvpy/view.py
View
@@ -579,7 +579,7 @@ def __init__(self, config, notes_list_model):
utils.SubjectMixin.__init__(self)
self.config = config
- self.taglist = []
+ self.taglist = None
notes_list_model.add_observer('set:list', self.observer_notes_list)
self.notes_list_model = notes_list_model
@@ -1467,21 +1467,32 @@ def set_note_data(self, note, reset_undo=True, content_unchanged=False):
def set_notes(self, notes):
+ # this method is called by View.observer_notes_list()
+
# clear the notes list
self.notes_list.clear()
taglist = []
-
+
for o in notes:
tags = o.note.get('tags')
if tags:
taglist += tags
+
self.notes_list.append(o.note, utils.KeyValueObject(tagfound=o.tagfound))
- taglist = list(set(self.taglist + taglist))
- if len(taglist) > len(self.taglist):
- self.taglist=taglist
+ if self.taglist is None:
+ # first time we get called, so we need to initialise
+ self.taglist = taglist
self.search_entry.set_completion_list(self.taglist)
+ else:
+ # only set completion list if the new combined taglist is larger.
+ taglist = list(set(self.taglist + taglist))
+ if len(taglist) > len(self.taglist):
+ self.taglist=taglist
+ self.search_entry.set_completion_list(self.taglist)
+
+
def show_error(self, title, msg):
tkMessageBox.showerror(title, msg)

0 comments on commit 166e0bd

Please sign in to comment.