diff options
| author | dam <dam@gudinoff> | 2023-04-20 09:43:41 +0100 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2023-04-20 09:43:41 +0100 |
| commit | 804dd0a008b9e3ecaecae217cbbd18c7d6d5a502 (patch) | |
| tree | 43445c2eaee937974e3f0d4a0145d020ef0b3f2b | |
| parent | 7ff77e19362bf0c01e7ba34df5dd968bd9d14b3d (diff) | |
| download | task-time-tracker-804dd0a008b9e3ecaecae217cbbd18c7d6d5a502.tar.zst task-time-tracker-804dd0a008b9e3ecaecae217cbbd18c7d6d5a502.zip | |
Fixed bug on sort by feature: now it keeps track of active task.
| -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. |
