summaryrefslogtreecommitdiff
path: root/internal/task/task.go
diff options
context:
space:
mode:
authorPaul Bütow <1224732+snonux@users.noreply.github.com>2025-06-20 20:35:07 +0300
committerGitHub <noreply@github.com>2025-06-20 20:35:07 +0300
commitd596388ebe915d164a9df22dae57be5f9fc2e465 (patch)
treead3e782dc56f7a868514a3215e132a208533e101 /internal/task/task.go
parenta9e322ff7e83364868dc56fd9ac1d8acbc5ce08b (diff)
parentedec7717bdea74d11ec806ad5a98e26e9d3b7d0e (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.go15
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
}
}