From 8e5418664943b5a969ef45a23db155d6eca78e22 Mon Sep 17 00:00:00 2001 From: Conatum Date: Mon, 11 Sep 2023 11:17:59 +0300 Subject: [PATCH] fix(tasklist): Fix sub menu labelling. --- src/modules/tasklist/ui.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/modules/tasklist/ui.py b/src/modules/tasklist/ui.py index 19acc6a3..76f4837a 100644 --- a/src/modules/tasklist/ui.py +++ b/src/modules/tasklist/ui.py @@ -381,9 +381,10 @@ class TasklistUI(BasePager): def _format_parent(self, parentid) -> str: parentstr = '' if parentid is not None: - task = self.tasklist.tasklist.get(parentid, None) - if task: - parent_label = self.tasklist.format_label(self.tasklist.labelid(parentid)).strip('.') + pair = next(((label, task) for label, task in self.labelled.items() if task.taskid == parentid), None) + if pair is not None: + label, task = pair + parent_label = self.tasklist.format_label(label).strip('.') parentstr = f"{parent_label}: {task.content}" return parentstr @@ -561,8 +562,8 @@ class TasklistUI(BasePager): label=self.tasklist.format_label(rootlabel).strip('.'), ) children = { - label: taskid - for label, taskid in labelled.items() + label: task + for label, task in labelled.items() if all(i == j for i, j in zip(label, rootlabel)) } this_page = self.this_page @@ -572,11 +573,13 @@ class TasklistUI(BasePager): else: # Only show the children which display page_children = [ - (label, tid) for label, tid in this_page if label in children and tid != rootid + (label, task) for label, task in this_page if label in children and task.taskid != rootid ][:24] if page_children: - block = [(rootlabel, rootid), *page_children] + # Always add the root task + block = [(rootlabel, self.tasklist.tasklist[rootid]), *page_children] else: + # There are no subtree children on the current page block = [] # Special case if the subtree is exactly the same as the page if not (len(block) == len(this_page) and all(i[0] == j[0] for i, j in zip(block, this_page))):