From 617b1ea6d1853269f96a410d49d244deddeb0b50 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Thu, 3 Oct 2024 13:29:41 +0200 Subject: [PATCH] fix(tasks): do not show children of non-matching states --- src/tasks.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/tasks.rs b/src/tasks.rs index fa7ebe2..d203c8a 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -381,19 +381,21 @@ impl TasksRelay { depth: usize, ) -> Vec<&'a Task> { iter.flat_map(move |task| { - let new_depth = depth - 1; - if new_depth > 0 { - let mut children = self.resolve_tasks_rec(self.tasks.children_of(&task), sparse, new_depth); - if !children.is_empty() { - if !sparse { - children.push(task); - } - return children; + if !self.state.matches(task) { + return vec![] + } + let new_depth = depth - 1; + if new_depth > 0 { + let mut children = self.resolve_tasks_rec(self.tasks.children_of(&task), sparse, new_depth); + if !children.is_empty() { + if !sparse { + children.push(task); } + return children; } - return if self.filter(task) { vec![task] } else { vec![] }; - }) - .collect_vec() + } + return if self.filter(task) { vec![task] } else { vec![] }; + }).collect_vec() } /// Executes the given function with each task referenced by this event without marker.