From 12d363df5ef1d0cfb2ba809bb4d2a57f1e529f27 Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Sat, 26 Dec 2020 12:43:07 +0100 Subject: [PATCH] completion: Fix compatibility with taskwarrior 2.4.4 --- taskwiki/completion.py | 18 +++++++++++++----- tests/test_completion.py | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/taskwiki/completion.py b/taskwiki/completion.py index ea2c8fa..a2df7eb 100644 --- a/taskwiki/completion.py +++ b/taskwiki/completion.py @@ -1,6 +1,8 @@ from functools import reduce, wraps import re +from tasklib import TaskWarrior + from taskwiki import constants @@ -53,14 +55,20 @@ class Completion(): @cached_property def _tags(self): - return sorted(set( - tag - for tags in self.tw.execute_command(['_unique', 'tag']) - for tag in tags.split(','))) + if self.tw.version < TaskWarrior.VERSION_2_4_5: + return sorted(self.tw.execute_command(['_tags'])) + else: + return sorted(set( + tag + for tags in self.tw.execute_command(['_unique', 'tag']) + for tag in tags.split(','))) @cached_property def _projects(self): - return sorted(self.tw.execute_command(['_unique', 'project'])) + if self.tw.version < TaskWarrior.VERSION_2_4_5: + return sorted(self.tw.execute_command(['_projects'])) + else: + return sorted(self.tw.execute_command(['_unique', 'project'])) def _complete_any(self, w): if w: diff --git a/tests/test_completion.py b/tests/test_completion.py index c9e8075..5ffe3ff 100644 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -5,6 +5,7 @@ from tests.base import IntegrationTest class FakeTW(): def __init__(self, projects=[], tags=[]): + self.version = '2.5.1' self.projects = projects self.tags = tags