Skip to content
Open
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
8 changes: 5 additions & 3 deletions internal/tui/datetime.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ func (p *dateTimePicker) handleKey(msg tea.KeyPressMsg) tea.Cmd {
p.shiftDate(days)
return nil
}
// "-" cannot appear in a YYYY-MM-DD date, so swallow it here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The dateStep doc comment still says "a + or a - cannot appear in YYYY-MM-DD, so typing one is only ever a step," but - is no longer handled in dateStep — it is now swallowed by the new msg.String() == "-" branch in handleKey. Update the comment so it doesn't claim - is a step in dateStep.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/tui/datetime.go, line 240:

<comment>The `dateStep` doc comment still says "a + or a - cannot appear in YYYY-MM-DD, so typing one is only ever a step," but `-` is no longer handled in `dateStep` — it is now swallowed by the new `msg.String() == "-"` branch in `handleKey`. Update the comment so it doesn't claim `-` is a step in `dateStep`.</comment>

<file context>
@@ -237,6 +237,11 @@ func (p *dateTimePicker) handleKey(msg tea.KeyPressMsg) tea.Cmd {
 			p.shiftDate(days)
 			return nil
 		}
+		// "-" cannot appear in a YYYY-MM-DD date, so swallow it here
+		// instead of letting it through to the text input (hey-cli#368)
+		if msg.String() == "-" {
</file context>

// instead of letting it through to the text input (hey-cli#368)
if msg.String() == "-" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The change also removes the down-arrow date decrement, which is outside the PR's stated scope (only stopping - from stepping). In dateStep the case tea.KeyDown: return -1, true branch was dropped along with the - branch, so pressing the down arrow on the date field now does nothing, whereas on main it moved the date back one day. This regresses functionality and contradicts the still-advertised help binding {"↑↓", "day"}, which tells the reader the down arrow adjusts the day. Restore the KeyDown decrement and keep only the -/"=" handling, or intentionally remove the down arrow and update the help text to match.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/tui/datetime.go, line 242:

<comment>The change also removes the down-arrow date decrement, which is outside the PR's stated scope (only stopping `-` from stepping). In `dateStep` the `case tea.KeyDown: return -1, true` branch was dropped along with the `-` branch, so pressing the down arrow on the date field now does nothing, whereas on `main` it moved the date back one day. This regresses functionality and contradicts the still-advertised help binding `{"↑↓", "day"}`, which tells the reader the down arrow adjusts the day. Restore the KeyDown decrement and keep only the `-`/`"="` handling, or intentionally remove the down arrow and update the help text to match.</comment>

<file context>
@@ -237,6 +237,11 @@ func (p *dateTimePicker) handleKey(msg tea.KeyPressMsg) tea.Cmd {
 		}
+		// "-" cannot appear in a YYYY-MM-DD date, so swallow it here
+		// instead of letting it through to the text input (hey-cli#368)
+		if msg.String() == "-" {
+			return nil
+		}
</file context>

return nil
}
var cmd tea.Cmd
p.dateInput, cmd = p.dateInput.Update(msg)
return cmd
Expand All @@ -263,13 +268,10 @@ func dateStep(msg tea.KeyPressMsg) (days int, stepped bool) {
case tea.KeyUp:
return 1, true
case tea.KeyDown:
return -1, true
}
switch msg.String() {
case "+", "=":
return 1, true
case "-":
return -1, true
}
return 0, false
}
Expand Down
12 changes: 6 additions & 6 deletions internal/tui/datetime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ func TestDateTimePickerStepsTheDateByADay(t *testing.T) {
t.Errorf("after up, date() = %q, want 2026-08-23", got)
}

picker.handleKey(tea.KeyPressMsg{Code: tea.KeyDown})
picker.handleKey(tea.KeyPressMsg{Code: tea.KeyDown})
if got := picker.date(); got != "2026-08-21" {
t.Errorf("after two downs, date() = %q, want 2026-08-21", got)
// "-" no longer steps date (hey-cli#368)
typeInto(t, picker, "-")
if got := picker.date(); got != "2026-08-23" {
t.Errorf("after -, date() = %q, want unchanged", got)
}

typeInto(t, picker, "+")
if got := picker.date(); got != "2026-08-22" {
t.Errorf("after +, date() = %q, want 2026-08-22", got)
if got := picker.date(); got != "2026-08-24" {
t.Errorf("after +, date() = %q, want 2026-08-24", got)
}

picker.dateInput.SetValue("next tuesday")
Expand Down