forked from janek/mostr
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 {
|
||||
None => {
|
||||
debug!("Flushing Tasks because of empty command");
|
||||
tasks.flush()
|
||||
tasks.flush();
|
||||
}
|
||||
|
||||
Some(':') => {
|
||||
|
@ -599,7 +599,7 @@ async fn main() -> Result<()> {
|
|||
Some(arg) => {
|
||||
if parse_tracking_stamp(arg).and_then(|stamp| tasks.track_at(stamp, None)).is_some() {
|
||||
let (label, times) = tasks.times_tracked();
|
||||
println!("{}\n{}", label.italic(),
|
||||
println!("{}\n{}", label.italic(),
|
||||
times.rev().take(15).collect_vec().iter().rev().join("\n"));
|
||||
}
|
||||
// So the error message is not covered up
|
||||
|
|
|
@ -76,6 +76,7 @@ impl Task {
|
|||
self.find_refs(MARKER_DEPENDS).collect()
|
||||
}
|
||||
|
||||
/// Trimmed event content or stringified id
|
||||
pub(crate) fn get_title(&self) -> String {
|
||||
Some(self.event.content.trim().to_string())
|
||||
.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
|
||||
}
|
||||
|
||||
// TODO binary search
|
||||
/// Gets last position change before the given timestamp
|
||||
fn get_position_at(&self, timestamp: Timestamp) -> (Timestamp, Option<&EventId>) {
|
||||
self.history_from(timestamp)
|
||||
.last()
|
||||
|
@ -579,7 +581,7 @@ impl Tasks {
|
|||
let has_space = lowercase_arg.split_ascii_whitespace().count() > 1;
|
||||
|
||||
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) {
|
||||
let lowercase = task.event.content.to_ascii_lowercase();
|
||||
if lowercase == lowercase_arg {
|
||||
|
@ -587,7 +589,7 @@ impl Tasks {
|
|||
} else if task.event.content.starts_with(arg) {
|
||||
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)) } {
|
||||
filtered_more.push(task.event.id)
|
||||
filtered_fuzzy.push(task.event.id)
|
||||
}
|
||||
}
|
||||
for task in self.tasks.values() {
|
||||
|
@ -600,7 +602,7 @@ impl Tasks {
|
|||
}
|
||||
|
||||
if filtered.is_empty() {
|
||||
filtered = filtered_more;
|
||||
filtered = filtered_fuzzy;
|
||||
}
|
||||
let pos = self.get_position_ref();
|
||||
let immediate = filtered.iter().filter(
|
||||
|
@ -872,7 +874,7 @@ impl Tasks {
|
|||
.is_some_and(|t| t.event.content.to_ascii_lowercase().contains(&lower)));
|
||||
if let Some(event) = found {
|
||||
self.move_to(referenced_events(event).cloned());
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
false
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue