diff options
| author | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2025-06-20 20:35:07 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-20 20:35:07 +0300 |
| commit | d596388ebe915d164a9df22dae57be5f9fc2e465 (patch) | |
| tree | ad3e782dc56f7a868514a3215e132a208533e101 /internal/task/task.go | |
| parent | a9e322ff7e83364868dc56fd9ac1d8acbc5ce08b (diff) | |
| parent | edec7717bdea74d11ec806ad5a98e26e9d3b7d0e (diff) | |
Merge pull request #28 from snonux/codex/fix-a-hotkey-functionality
Fix annotation replacement
Diffstat (limited to 'internal/task/task.go')
| -rw-r--r-- | internal/task/task.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/internal/task/task.go b/internal/task/task.go index f328838..fb07333 100644 --- a/internal/task/task.go +++ b/internal/task/task.go @@ -171,8 +171,15 @@ func Annotate(id int, text string) error { } // Denotate removes an annotation from the task with the given id. -func Denotate(id int, annoID int) error { - return run(strconv.Itoa(id), "denotate", strconv.Itoa(annoID)) +// Denotate removes an annotation from the task with the given id. The +// annotation text is matched exactly when provided. If text is empty, the +// oldest annotation is removed. +func Denotate(id int, text string) error { + args := []string{strconv.Itoa(id), "denotate"} + if text != "" { + args = append(args, text) + } + return run(args...) } // ReplaceAnnotations removes all existing annotations from the task with the @@ -187,8 +194,8 @@ func ReplaceAnnotations(id int, text string) error { return fmt.Errorf("task %d not found", id) } anns := tasks[0].Annotations - for i := len(anns); i >= 1; i-- { - if err := Denotate(id, i); err != nil { + for i := len(anns) - 1; i >= 0; i-- { + if err := Denotate(id, anns[i].Description); err != nil { return err } } |
