diff --git a/doc/taskwiki.txt b/doc/taskwiki.txt index 790e27641..620feadc3 100644 --- a/doc/taskwiki.txt +++ b/doc/taskwiki.txt @@ -405,7 +405,7 @@ Examples: ----------------------- 5.2.5 Meta virtual tags -Currently there is one meta virtual tag: -VISIBLE. This tag can be used to +Currently there is one meta virtual tag: VISIBLE. This tag can be used to filter out tasks that are displayed elsewhere in the same taskwiki file. Example: @@ -414,6 +414,15 @@ Example: ~ == Work coding tasks | project:Work.Coding == ~ == Work review tasks | project:Work.Review == +Reversely, it can be used to display under a viewport only tasks that are +already displayed in the same taskwiki file. + +Example: + +~ == All work tasks by priority | +VISIBLE +~ == Task for main work | project:Work.main == +~ == Tasks for weekend work | project:Work.weekend == + ---------------- 5.2.6 Inspection diff --git a/taskwiki/viewport.py b/taskwiki/viewport.py index c20c447bb..38262db50 100644 --- a/taskwiki/viewport.py +++ b/taskwiki/viewport.py @@ -29,7 +29,7 @@ class ViewPort(object): * [ ] Make sure the hosting is working """ - meta_tokens = ('-VISIBLE',) + meta_tokens = ('-VISIBLE', '+VISIBLE') def __init__(self, line_number, cache, tw, name, filterstring, defaultstring, sort=None): @@ -171,6 +171,8 @@ def get_complement_tag(tag): for token in taskfilter_args: if token == '-VISIBLE': meta['visible'] = False + elif token == '+VISIBLE': + meta['visible'] = True taskfilter_args = [x for x in taskfilter_args if x not in self.meta_tokens] @@ -282,7 +284,7 @@ def matching_tasks(self): task for task in self.tw.tasks.filter(*args) ) # -VISIBLE virtual tag used - elif self.meta.get('visible') is False: + elif self.meta.get('visible') is not None: # Determine which tasks are outside the viewport all_vwtasks = set(self.cache.vwtask.values()) vwtasks_outside_viewport = all_vwtasks - set(self.tasks) @@ -291,12 +293,20 @@ def matching_tasks(self): if t is not None ) - # Return only those that are not duplicated outside - # of the viewport - return set( - task for task in self.tw.tasks.filter(*args) - if task not in tasks_outside_viewport - ) + if not self.meta['visible']: + # Return only those that are not duplicated outside + # of the viewport + return set( + task for task in self.tw.tasks.filter(*args) + if task not in tasks_outside_viewport + ) + else: + # Return only those that are duplicated outside + # of the viewport + return set( + task for task in self.tw.tasks.filter(*args) + if task in tasks_outside_viewport + ) def get_tasks_to_add_and_del(self): # Find the tasks that are new and tasks that are no longer diff --git a/tests/test_viewport.py b/tests/test_viewport.py index d3b440ac5..1ffa54a62 100644 --- a/tests/test_viewport.py +++ b/tests/test_viewport.py @@ -279,7 +279,7 @@ def execute(self): assert self.py("print(vim.current.buffer)", regex="') + self.client.eval('0') # wait for command completion + + assert self.py("print(vim.current.buffer)", regex="