feat(main): fallback to case-insensitive filter
This commit is contained in:
parent
e255ce0676
commit
cdd6981bf6
|
@ -24,12 +24,15 @@ Recommendation: Flat hierarchy, using tags for filtering (TBI)
|
|||
|
||||
### Command Syntax
|
||||
|
||||
TASK add syntax: `NAME: TAG1 TAG2 ...`
|
||||
`TASK` creation syntax: `NAME: TAG1 TAG2 ...`
|
||||
|
||||
- `TASK` - create task
|
||||
- `.` - clear filters and reload
|
||||
- `.TASK` - filter / activate (by id or name) / create & activate task
|
||||
- `.NUM` - set view depth - how many subtask levels to show
|
||||
- `.TASK`
|
||||
+ select task by id
|
||||
+ match by task name prefix: if one or more tasks match, filter / activate (tries case-sensitive then case-insensitive)
|
||||
+ no match: create & activate task
|
||||
- `.2` - set view depth to `2`, which can be substituted for any number (how many subtask levels to show, default 1)
|
||||
|
||||
Dots can be repeated to move to parent tasks
|
||||
|
||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -294,12 +294,23 @@ async fn main() {
|
|||
// TODO check what is more intuitive:
|
||||
// currently resets filters before filtering again, maybe keep them
|
||||
tasks.move_to(pos);
|
||||
let filtered: Vec<EventId> = tasks
|
||||
let mut filtered: Vec<EventId> = tasks
|
||||
.current_tasks()
|
||||
.into_iter()
|
||||
.filter(|t| t.event.content.starts_with(slice))
|
||||
.map(|t| t.event.id)
|
||||
.collect();
|
||||
if filtered.is_empty() {
|
||||
let lowercase = slice.to_ascii_lowercase();
|
||||
filtered = tasks
|
||||
.current_tasks()
|
||||
.into_iter()
|
||||
.filter(|t| {
|
||||
t.event.content.to_ascii_lowercase().starts_with(&lowercase)
|
||||
})
|
||||
.map(|t| t.event.id)
|
||||
.collect();
|
||||
}
|
||||
match filtered.len() {
|
||||
0 => {
|
||||
// No match, new task
|
||||
|
|
Loading…
Reference in New Issue