summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Bütow <1224732+snonux@users.noreply.github.com>2025-06-21 21:14:26 +0300
committerPaul Bütow <1224732+snonux@users.noreply.github.com>2025-06-21 21:14:26 +0300
commitb41781c9718e0c38dd3d39559ac84360923ef7e7 (patch)
tree046f11cc3b9e715dfd46d807c9e13c25592888c0
parent011f4e7880b1548abb86a3d2f78f80e167004ebd (diff)
Add tag editing hotkey and diff-based tag updates
-rw-r--r--internal/ui/table.go36
1 files changed, 34 insertions, 2 deletions
diff --git a/internal/ui/table.go b/internal/ui/table.go
index 4f7c2d6..5ea744c 100644
--- a/internal/ui/table.go
+++ b/internal/ui/table.go
@@ -259,8 +259,28 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if m.tagsEditing {
switch msg.Type {
case tea.KeyEnter:
- tags := strings.Fields(m.tagsInput.Value())
- task.SetTags(m.tagsID, tags)
+ words := strings.Fields(m.tagsInput.Value())
+ var adds, removes []string
+ for _, w := range words {
+ if strings.HasPrefix(w, "-") {
+ if len(w) > 1 {
+ removes = append(removes, w[1:])
+ }
+ } else {
+ if strings.HasPrefix(w, "+") {
+ w = w[1:]
+ }
+ if w != "" {
+ adds = append(adds, w)
+ }
+ }
+ }
+ if len(adds) > 0 {
+ task.AddTags(m.tagsID, adds)
+ }
+ if len(removes) > 0 {
+ task.RemoveTags(m.tagsID, removes)
+ }
m.tagsEditing = false
m.tagsInput.Blur()
m.reload()
@@ -484,6 +504,18 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, nil
}
}
+ case "t":
+ if row := m.tbl.SelectedRow(); row != nil {
+ idStr := ansi.Strip(row[0])
+ if id, err := strconv.Atoi(idStr); err == nil {
+ m.tagsID = id
+ m.tagsEditing = true
+ m.tagsInput.SetValue(strings.Join(m.tasks[m.tbl.Cursor()].Tags, " "))
+ m.tagsInput.Focus()
+ m.updateTableHeight()
+ return m, nil
+ }
+ }
case "/", "?":
m.searching = true
m.searchInput.SetValue("")