forked from janek/mostr
feat: properly include tasks with hashtags in filters
This commit is contained in:
parent
ddb68f7107
commit
0744e86922
|
@ -78,11 +78,14 @@ impl Task {
|
||||||
|
|
||||||
/// Trimmed event content or stringified id
|
/// Trimmed event content or stringified id
|
||||||
pub(crate) fn get_title(&self) -> String {
|
pub(crate) fn get_title(&self) -> String {
|
||||||
Some(self.event.content.trim().to_string())
|
some_non_empty(self.event.content.trim())
|
||||||
.filter(|s| !s.is_empty())
|
|
||||||
.unwrap_or_else(|| self.get_id().to_string())
|
.unwrap_or_else(|| self.get_id().to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_filter_title(&self) -> String {
|
||||||
|
self.event.content.trim().trim_start_matches('#').to_string()
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn description_events(&self) -> impl Iterator<Item=&Event> + '_ {
|
pub(crate) fn description_events(&self) -> impl Iterator<Item=&Event> + '_ {
|
||||||
self.props.iter().filter(|event| event.kind == Kind::TextNote)
|
self.props.iter().filter(|event| event.kind == Kind::TextNote)
|
||||||
}
|
}
|
||||||
|
|
11
src/tasks.rs
11
src/tasks.rs
|
@ -670,20 +670,21 @@ impl Tasks {
|
||||||
let mut filtered: Vec<EventId> = Vec::with_capacity(32);
|
let mut filtered: Vec<EventId> = Vec::with_capacity(32);
|
||||||
let mut filtered_fuzzy: Vec<EventId> = Vec::with_capacity(32);
|
let mut filtered_fuzzy: Vec<EventId> = Vec::with_capacity(32);
|
||||||
for task in self.filtered_tasks(position, false) {
|
for task in self.filtered_tasks(position, false) {
|
||||||
let lowercase = task.event.content.to_ascii_lowercase();
|
let content = task.get_filter_title();
|
||||||
|
let lowercase = content.to_ascii_lowercase();
|
||||||
if lowercase == lowercase_arg {
|
if lowercase == lowercase_arg {
|
||||||
return vec![task.event.id];
|
return vec![task.event.id];
|
||||||
} else if task.event.content.starts_with(arg) {
|
} else if content.starts_with(arg) {
|
||||||
filtered.push(task.event.id)
|
filtered.push(task.event.id)
|
||||||
} else if if has_space { lowercase.starts_with(&lowercase_arg) } else { lowercase.split_ascii_whitespace().any(|word| word.starts_with(&lowercase_arg)) } {
|
} else if if has_space { lowercase.starts_with(&lowercase_arg) } else { lowercase.split_ascii_whitespace().any(|word| word.trim_start_matches('#').starts_with(&lowercase_arg)) } {
|
||||||
filtered_fuzzy.push(task.event.id)
|
filtered_fuzzy.push(task.event.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for task in self.tasks.values() {
|
for task in self.tasks.values() {
|
||||||
// Find global exact match
|
// Find global exact match
|
||||||
if task.event.content.to_ascii_lowercase() == lowercase_arg &&
|
if task.get_filter_title().to_ascii_lowercase() == lowercase_arg &&
|
||||||
!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
|
||||||
|
!self.traverse_up_from(Some(*task.get_id())).any(|t| t.pure_state() == State::Closed) {
|
||||||
return vec![task.event.id];
|
return vec![task.event.id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue