Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions internal/tui/tui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,27 @@ func TestLedgerEditFollowsSelection(t *testing.T) {
}
}

func TestLedgerCopyFollowsSelection(t *testing.T) {
today := time.Date(2026, 7, 10, 12, 0, 0, 0, time.Local)
projectPath := t.TempDir()
seedLog(t, projectPath, "2026/07/08", "- copy me\n")

m := newLedgerModel(t, projectPath, today)
m.moveLedgerCursor(1) // select 2026/07/08
if day, _ := m.selectedDay(); day != "2026/07/08" {
t.Fatalf("expected 2026/07/08 selected, got %s", day)
}

mm, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'y'}})
if cmd == nil {
t.Fatal("expected a copy cmd for the selected day")
}
// don't execute it — that would touch the real clipboard
if mm.(Model).mode != modeLedger {
t.Error("expected to stay on the ledger after copying")
}
}

func TestLedgerNewDayRow(t *testing.T) {
today := time.Date(2026, 7, 10, 12, 0, 0, 0, time.Local)
projectPath := t.TempDir()
Expand Down
12 changes: 7 additions & 5 deletions internal/tui/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,13 @@ func (m Model) onLedgerKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
}
return m, openEditor(m.projectPath, day)

case key.Matches(msg, m.keys.Copy):
day, ok := m.selectedDay()
if !ok {
return m, nil
}
return m, copyDay(m.projectPath, day)

case key.Matches(msg, m.keys.Older):
m.moveLedgerCursor(1) // older = further down the newest-first list
return m, nil
Expand All @@ -365,11 +372,6 @@ func (m Model) onLedgerKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
m.status = ""
return m, m.refresh()

case key.Matches(msg, m.keys.Help):
m.help.ShowAll = !m.help.ShowAll
m.layout()
return m, nil

case msg.String() == "n" || key.Matches(msg, m.keys.Search):
// both start the filter/new-day prompt in place
m.status = ""
Expand Down
2 changes: 1 addition & 1 deletion internal/tui/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ func (m Model) footerView() string {
if m.dayFilter.Focused() {
return footer.Render("filter by date or text • ↑/↓ move • enter open • esc clear")
}
return footer.Render("↑/↓ move • enter open • a append • n new day • / filter • r refresh • p project • ? help")
return footer.Render("↑/↓ move • enter open • a append • e edit • y copy • n new day • / filter • r refresh • p project")
}

if m.status != "" {
Expand Down
Loading