From 5f7814edd9afbe95743972737789efb026687f6d Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Mon, 10 Aug 2015 01:14:51 +0200 Subject: [PATCH] ViewPort: Add newly matched tasks to the cache and viewport set container properly --- taskwiki/viewport.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/taskwiki/viewport.py b/taskwiki/viewport.py index d6a90db..1278d15 100644 --- a/taskwiki/viewport.py +++ b/taskwiki/viewport.py @@ -221,13 +221,14 @@ class ViewPort(object): # Add the tasks that match the filter and are not listed added_tasks = 0 + existing_tasks = len(self.tasks) sorted_to_add = list(to_add) sorted_to_add.sort(key=lambda x:x['entry']) for task in sorted_to_add: added_tasks += 1 - added_at = self.line_number + len(self.tasks) + added_tasks + added_at = self.line_number + existing_tasks + added_tasks # Add the task object to cache self.cache[vwtask.ShortUUID(task['uuid'], self.tw)] = task @@ -235,9 +236,10 @@ class ViewPort(object): # Create the VimwikiTask vimwikitask = vwtask.VimwikiTask.from_task(self.cache, task) vimwikitask['line_number'] = added_at - - # Save it to cache - self.cache[added_at] = vimwikitask + self.tasks.add(vimwikitask) # Update the buffer self.cache.insert_line(str(vimwikitask), added_at) + + # Save it to cache + self.cache[added_at] = vimwikitask