style: slight reformatting
This commit is contained in:
parent
c2b106ea69
commit
d4f544173a
3 changed files with 9 additions and 6 deletions
|
@ -375,7 +375,7 @@ async fn main() -> Result<()> {
|
||||||
match op {
|
match op {
|
||||||
None => {
|
None => {
|
||||||
debug!("Flushing Tasks because of empty command");
|
debug!("Flushing Tasks because of empty command");
|
||||||
tasks.flush()
|
tasks.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(':') => {
|
Some(':') => {
|
||||||
|
|
|
@ -76,6 +76,7 @@ impl Task {
|
||||||
self.find_refs(MARKER_DEPENDS).collect()
|
self.find_refs(MARKER_DEPENDS).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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(self.event.content.trim().to_string())
|
||||||
.filter(|s| !s.is_empty())
|
.filter(|s| !s.is_empty())
|
||||||
|
|
10
src/tasks.rs
10
src/tasks.rs
|
@ -155,6 +155,8 @@ impl Tasks {
|
||||||
self.get_position_at(now()).1
|
self.get_position_at(now()).1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO binary search
|
||||||
|
/// Gets last position change before the given timestamp
|
||||||
fn get_position_at(&self, timestamp: Timestamp) -> (Timestamp, Option<&EventId>) {
|
fn get_position_at(&self, timestamp: Timestamp) -> (Timestamp, Option<&EventId>) {
|
||||||
self.history_from(timestamp)
|
self.history_from(timestamp)
|
||||||
.last()
|
.last()
|
||||||
|
@ -579,7 +581,7 @@ impl Tasks {
|
||||||
let has_space = lowercase_arg.split_ascii_whitespace().count() > 1;
|
let has_space = lowercase_arg.split_ascii_whitespace().count() > 1;
|
||||||
|
|
||||||
let mut filtered: Vec<EventId> = Vec::with_capacity(32);
|
let mut filtered: Vec<EventId> = Vec::with_capacity(32);
|
||||||
let mut filtered_more: Vec<EventId> = Vec::with_capacity(32);
|
let mut filtered_fuzzy: Vec<EventId> = Vec::with_capacity(32);
|
||||||
for task in self.filtered_tasks(position) {
|
for task in self.filtered_tasks(position) {
|
||||||
let lowercase = task.event.content.to_ascii_lowercase();
|
let lowercase = task.event.content.to_ascii_lowercase();
|
||||||
if lowercase == lowercase_arg {
|
if lowercase == lowercase_arg {
|
||||||
|
@ -587,7 +589,7 @@ impl Tasks {
|
||||||
} else if task.event.content.starts_with(arg) {
|
} else if task.event.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.starts_with(&lowercase_arg)) } {
|
||||||
filtered_more.push(task.event.id)
|
filtered_fuzzy.push(task.event.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for task in self.tasks.values() {
|
for task in self.tasks.values() {
|
||||||
|
@ -600,7 +602,7 @@ impl Tasks {
|
||||||
}
|
}
|
||||||
|
|
||||||
if filtered.is_empty() {
|
if filtered.is_empty() {
|
||||||
filtered = filtered_more;
|
filtered = filtered_fuzzy;
|
||||||
}
|
}
|
||||||
let pos = self.get_position_ref();
|
let pos = self.get_position_ref();
|
||||||
let immediate = filtered.iter().filter(
|
let immediate = filtered.iter().filter(
|
||||||
|
@ -872,7 +874,7 @@ impl Tasks {
|
||||||
.is_some_and(|t| t.event.content.to_ascii_lowercase().contains(&lower)));
|
.is_some_and(|t| t.event.content.to_ascii_lowercase().contains(&lower)));
|
||||||
if let Some(event) = found {
|
if let Some(event) = found {
|
||||||
self.move_to(referenced_events(event).cloned());
|
self.move_to(referenced_events(event).cloned());
|
||||||
return true
|
return true;
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue