forked from janek/mostr
1
0
Fork 0

feat: prefer immediate children search results

This commit is contained in:
xeruf 2024-08-29 12:11:43 +03:00
parent 039c390c66
commit 003d1d6120
1 changed files with 9 additions and 1 deletions

View File

@ -591,14 +591,22 @@ impl Tasks {
} }
} }
for task in self.tasks.values() { for task in self.tasks.values() {
// Find global exact match
if task.event.content.to_ascii_lowercase() == lowercase_arg && if task.event.content.to_ascii_lowercase() == lowercase_arg &&
!self.traverse_up_from(Some(*task.get_id())).any(|t| t.pure_state() == State::Closed) { !self.traverse_up_from(Some(*task.get_id())).any(|t| t.pure_state() == State::Closed) {
// exclude closed tasks and their subtasks // exclude closed tasks and their subtasks
return vec![task.event.id]; return vec![task.event.id];
} }
} }
if filtered.is_empty() { if filtered.is_empty() {
return filtered_more; filtered = filtered_more;
}
let pos = self.get_position_ref();
let immediate = filtered.iter().filter(
|t| self.get_by_id(t).is_some_and(|t| t.parent_id() == pos)).collect_vec();
if immediate.len() == 1 {
return immediate.into_iter().cloned().collect_vec();
} }
filtered filtered
} }