From c09ad2afa420b0e4a558bf05a0672d5f9785d3ad Mon Sep 17 00:00:00 2001 From: ewy Date: Fri, 17 Apr 2026 13:20:45 +0200 Subject: allow left/right (h/l) to leap through sources instead of going one by one --- menu/input.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/menu/input.go b/menu/input.go index 5c75430..6d05749 100644 --- a/menu/input.go +++ b/menu/input.go @@ -5,6 +5,10 @@ import tea "github.com/charmbracelet/bubbletea" func (m *Model) HandleInput(msg tea.KeyMsg) (tea.Cmd, error) { var cmd tea.Cmd switch msg.String() { + case "h", "left": + m.Leap(-1) + case "l", "right": + m.Leap(1) case "up", "k": m.Index-- case "down", "j": @@ -20,3 +24,19 @@ func (m *Model) HandleInput(msg tea.KeyMsg) (tea.Cmd, error) { return cmd, nil } + +func (m *Model) Leap(direction int) { + for { + source, target := m.Result() + m.Index += direction + m.Validate() + newSource, newTarget := m.Result() + if target == newTarget { + return + } + + if source != newSource { + return + } + } +} -- cgit v1.3