diff options
| -rw-r--r-- | ttt.jai | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -1634,7 +1634,8 @@ main :: () { // Sort by. case #char "s"; #through; case #char "S"; - // BUG FIXME The `sort by` feature does not keep track of the currently active task. + // TODO The initial part should only decide what's the sorting procedure... then we would would all in a single place. + active_task: Task = ifx db.active_idx >= 0 then db.tasks[db.active_idx] else .{}; sort_by := read_input_char(selected_task_row, action_style, " Sort by (n) name, (1..7) day, or (t) total time. "); if sort_by == { case #char "n"; #through; @@ -1670,6 +1671,25 @@ main :: () { case 6; quick_sort(db.tasks, (x, y) => x.times[6] - y.times[6]); } } + if db.active_idx >= 0 { + + compare_array :: (a: [] $T, b: [] T) -> int { + for 0..min(a.count, b.count)-1 { + if a[it] > b[it] return 1; + if a[it] < b[it] return -1; + } + if a.count > b.count return 1; + if a.count < b.count return -1; + return 0; + } + + for db.tasks { + if compare(xx active_task.name, xx it.name) == 0 && compare_array(active_task.times, it.times) == 0 { + db.active_idx = it_index; + break; + } + } + } trigger_autosave(); // Workspace cleanup. |
