Skip to content

Commit

Permalink
Fixed not-initialised bug with NO tags in notes
Browse files Browse the repository at this point in the history
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 166e0bd
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions nvpy/view.py
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 166e0bd

Please sign in to comment.