-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds +VISIBLE metatag #307
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
def get_tasks_to_add_and_del(self): | ||
# Find the tasks that are new and tasks that are no longer | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,7 +279,7 @@ def execute(self): | |
assert self.py("print(vim.current.buffer)", regex="<buffer taskwiki.") | ||
|
||
|
||
class TestViewportInspectionWithVisibleTag(MultiSyntaxIntegrationTest): | ||
class TestViewportInspectionWithNonVisibleTag(MultiSyntaxIntegrationTest): | ||
|
||
viminput = """ | ||
HEADER2(Work tasks | +work -VISIBLE) | ||
|
@@ -315,6 +315,42 @@ def execute(self): | |
assert self.py("print(vim.current.buffer)", regex="<buffer taskwiki.") | ||
|
||
|
||
class TestViewportInspectionWithVisibleTag(MultiSyntaxIntegrationTest): | ||
|
||
viminput = """ | ||
HEADER2(Work tasks | +work +VISIBLE) | ||
|
||
HEADER2(Home tasks | +home) | ||
* [ ] tag work task #{uuid} | ||
""" | ||
|
||
vimoutput = """ | ||
ViewPort inspection: | ||
-------------------- | ||
Name: Work tasks | ||
Filter used: -DELETED -PARENT ( +work ) | ||
Defaults used: tags:['work'] | ||
Ordering used: status+,end+,due+,priority-,project+ | ||
Matching taskwarrior tasks: 0 | ||
Displayed tasks: 1 | ||
Tasks to be added: | ||
Tasks to be deleted: tag work task | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this intended? I'd appreciate a comment explaining what this test really tests, as I don't think it's obvious. :-/ |
||
""" | ||
|
||
tasks = [ | ||
dict(description="tag work task", tags=['work', 'home']), | ||
dict(description="tag work task 2", tags=['home']), | ||
] | ||
|
||
def execute(self): | ||
self.command("w", regex="written$", lines=1) | ||
self.client.feedkeys('1gg') | ||
self.client.feedkeys(r'\<CR>') | ||
self.client.eval('0') # wait for command completion | ||
|
||
assert self.py("print(vim.current.buffer)", regex="<buffer taskwiki.") | ||
|
||
|
||
class TestViewportsUnicodeTaskGeneration(MultiSyntaxIntegrationTest): | ||
|
||
viminput = """ | ||
|
@@ -545,7 +581,7 @@ def execute(self): | |
"'Work tasks' is not defined, using default.", lines=2) | ||
|
||
|
||
class TestViewportsVisibleMetaTag(MultiSyntaxIntegrationTest): | ||
class TestViewportsInvisibleMetaTag(MultiSyntaxIntegrationTest): | ||
|
||
viminput = """ | ||
HEADER2(Home tasks | project:Home -VISIBLE) | ||
|
@@ -572,6 +608,33 @@ def execute(self): | |
self.command("w", regex="written$", lines=1) | ||
|
||
|
||
class TestViewportsVisibleMetaTag(MultiSyntaxIntegrationTest): | ||
|
||
viminput = """ | ||
HEADER2(Home tasks | project:Home +VISIBLE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop the |
||
|
||
HEADER2(Chores | project:Home.Chores) | ||
""" | ||
|
||
vimoutput = """ | ||
HEADER2(Home tasks | project:Home +VISIBLE) | ||
* [ ] chore task #{uuid} | ||
|
||
HEADER2(Chores | project:Home.Chores) | ||
* [ ] chore task #{uuid} | ||
""" | ||
|
||
tasks = [ | ||
dict(description="home task", project='Home.Random'), | ||
dict(description="chore task", project='Home.Chores'), | ||
] | ||
|
||
def execute(self): | ||
# Currently, two saves are necessary for VISIBLE to take effect | ||
self.command("w", regex="written$", lines=1) | ||
self.command("w", regex="written$", lines=1) | ||
|
||
|
||
class TestViewportsPreserveHierarchyUponCompletion(MultiSyntaxIntegrationTest): | ||
|
||
viminput = """ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.