Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 166e0bd4eaaae36a20556e72969400b3976c2187 1 parent 350db3b
Charl P. Botha cpbotha authored

Showing 1 changed file with 16 additions and 5 deletions. Show diff stats Hide diff stats

  1. +16 5 nvpy/view.py
21 nvpy/view.py
@@ -579,7 +579,7 @@ def __init__(self, config, notes_list_model):
579 579 utils.SubjectMixin.__init__(self)
580 580
581 581 self.config = config
582   - self.taglist = []
  582 + self.taglist = None
583 583
584 584 notes_list_model.add_observer('set:list', self.observer_notes_list)
585 585 self.notes_list_model = notes_list_model
@@ -1467,21 +1467,32 @@ def set_note_data(self, note, reset_undo=True, content_unchanged=False):
1467 1467
1468 1468
1469 1469 def set_notes(self, notes):
  1470 + # this method is called by View.observer_notes_list()
  1471 +
1470 1472 # clear the notes list
1471 1473 self.notes_list.clear()
1472 1474 taglist = []
1473   -
  1475 +
1474 1476 for o in notes:
1475 1477 tags = o.note.get('tags')
1476 1478 if tags:
1477 1479 taglist += tags
  1480 +
1478 1481 self.notes_list.append(o.note, utils.KeyValueObject(tagfound=o.tagfound))
1479 1482
1480   - taglist = list(set(self.taglist + taglist))
1481   - if len(taglist) > len(self.taglist):
1482   - self.taglist=taglist
  1483 + if self.taglist is None:
  1484 + # first time we get called, so we need to initialise
  1485 + self.taglist = taglist
1483 1486 self.search_entry.set_completion_list(self.taglist)
1484 1487
  1488 + else:
  1489 + # only set completion list if the new combined taglist is larger.
  1490 + taglist = list(set(self.taglist + taglist))
  1491 + if len(taglist) > len(self.taglist):
  1492 + self.taglist=taglist
  1493 + self.search_entry.set_completion_list(self.taglist)
  1494 +
  1495 +
1485 1496 def show_error(self, title, msg):
1486 1497 tkMessageBox.showerror(title, msg)
1487 1498

0 comments on commit 166e0bd

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