From 0ac7da0fde54e5de1be07aabee5aa2588f34df73 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Fri, 27 Jan 2017 10:29:34 +0100 Subject: [PATCH] Mappings: Delegate to VimwikiFollowLink for link creation --- taskwiki/main.py | 7 ++++++- taskwiki/regexp.py | 4 ++-- tests/test_viewport.py | 25 +++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/taskwiki/main.py b/taskwiki/main.py index bfc3fa5..bfd5609 100644 --- a/taskwiki/main.py +++ b/taskwiki/main.py @@ -266,7 +266,7 @@ class Mappings(object): vim.command('VimwikiFollowLink') return - # No link detected, so it's our stuff now + # No link detected, check for viewport or a task if cache.vwtask[row] is not None: SelectedTasks().info() else: @@ -274,6 +274,11 @@ class Mappings(object): if port is not None: Meta().inspect_viewport() + # No link detected, not a viewport or a task, so delegate to + # VimwikiFollowLink for link creation + vim.command('VimwikiFollowLink') + + class Meta(object): diff --git a/taskwiki/regexp.py b/taskwiki/regexp.py index 04e360a..bd5a5df 100644 --- a/taskwiki/regexp.py +++ b/taskwiki/regexp.py @@ -19,7 +19,7 @@ TEXT = r'(?P.+?)' COMPLETION_MARK = r'(?P.)' PRIORITY = r'(?P!{1,3})' -GENERIC_TASK = re.compile(''.join([ +GENERIC_TASK = re.compile(u''.join([ '^', EMPTY_SPACE, BRACKET_OPENING, @@ -36,7 +36,7 @@ GENERIC_TASK = re.compile(''.join([ ')?', # UUID is not there for new tasks SPACE_UNNAMED, '$' # Enforce match on the whole line -])) +]), re.UNICODE) DATETIME_FORMAT = "(%Y-%m-%d %H:%M)" DATE_FORMAT = "(%Y-%m-%d)" diff --git a/tests/test_viewport.py b/tests/test_viewport.py index 74bfa06..9f83f59 100644 --- a/tests/test_viewport.py +++ b/tests/test_viewport.py @@ -599,3 +599,28 @@ class TestViewportsPreserveHierarchyUponCompletion(IntegrationTest): sleep(0.5) self.command("w", regex="written$", lines=1) sleep(0.5) + + +class TestViewportRecurrentInstanceTaskGeneration(IntegrationTest): + + viminput = """ + === Work tasks | +TODAY === + """ + + vimoutput = """ + === Work tasks | +TODAY === + * [ ] daily task #{uuid} + """ + + tasks = [ + dict(description="daily task", recur="daily", due="today"), + ] + + def execute(self): + self.command("w", regex="written$", lines=1) + + # Assert that the task did not change after another successful + # subsequent saving. See pull request #125. + self.command("w", regex="written$", lines=1) + task = self.tw.tasks.pending()[0] + assert task['description'] == "daily task"