@@ -95,25 +95,8 @@ func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
9595 return a , tea .Quit
9696 }
9797 if a .pendingInput != nil {
98- if componentsUsesVerticalPrompt (a .inputPrompt , a .pendingInput .Options ) {
99- switch msg .Type {
100- case tea .KeyUp :
101- a .inputPrompt = a .inputPrompt .SetSelectedIndex (a .inputPrompt .SelectedIndex () - 1 )
102- return a , nil
103- case tea .KeyDown :
104- a .inputPrompt = a .inputPrompt .SetSelectedIndex (a .inputPrompt .SelectedIndex () + 1 )
105- return a , nil
106- case tea .KeyEnter :
107- idx := a .inputPrompt .SelectedIndex ()
108- if idx >= 0 && idx < len (a .pendingInput .Options ) {
109- opt := a .pendingInput .Options [idx ]
110- a .lines = appendLine (a .lines , styledLine {text : formatResolvedInput (* a .pendingInput , opt .Key )})
111- responseCmd := sendInputResponseCmd (a .pendingInput .ResponseCh , output.InputResponse {SelectedKey : opt .Key })
112- a .pendingInput = nil
113- a .inputPrompt = a .inputPrompt .Hide ()
114- return a , responseCmd
115- }
116- }
98+ if a .pendingInput .Vertical {
99+ return a .handleVerticalPromptKey (msg )
117100 }
118101 if opt := resolveOption (a .pendingInput .Options , msg ); opt != nil {
119102 a .lines = appendLine (a .lines , styledLine {text : formatResolvedInput (* a .pendingInput , opt .Key )})
@@ -130,7 +113,7 @@ func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
130113 if a .spinner .Visible () {
131114 a .spinner = a .spinner .SetText (output .FormatPrompt (msg .Prompt , msg .Options ))
132115 } else {
133- a .inputPrompt = a .inputPrompt .Show (msg .Prompt , msg .Options )
116+ a .inputPrompt = a .inputPrompt .Show (msg .Prompt , msg .Options , msg . Vertical )
134117 }
135118 case spinner.TickMsg :
136119 var cmd tea.Cmd
@@ -315,20 +298,36 @@ func (a *App) flushBufferedLines() {
315298 a .bufferedLines = nil
316299}
317300
318- func formatResolvedInput (req output.UserInputRequestEvent , selectedKey string ) string {
319- // Special handling for lstk update prompt
320- if len (req .Options ) > 0 && strings .Contains (req .Options [0 ].Label , "Update now" ) {
321- checkmark := styles .Success .Render (output .SuccessMarker ())
322- switch selectedKey {
323- case "u" :
324- return checkmark + " Updating lstk..."
325- case "s" :
326- return checkmark + " Skipped this version"
327- case "n" :
328- return checkmark + " Won't ask again"
301+ func (a App ) handleVerticalPromptKey (msg tea.KeyMsg ) (tea.Model , tea.Cmd ) {
302+ switch msg .Type {
303+ case tea .KeyUp :
304+ a .inputPrompt = a .inputPrompt .SetSelectedIndex (a .inputPrompt .SelectedIndex () - 1 )
305+ return a , nil
306+ case tea .KeyDown :
307+ a .inputPrompt = a .inputPrompt .SetSelectedIndex (a .inputPrompt .SelectedIndex () + 1 )
308+ return a , nil
309+ case tea .KeyEnter :
310+ idx := a .inputPrompt .SelectedIndex ()
311+ if idx >= 0 && idx < len (a .pendingInput .Options ) {
312+ opt := a .pendingInput .Options [idx ]
313+ a .lines = appendLine (a .lines , styledLine {text : formatResolvedInput (* a .pendingInput , opt .Key )})
314+ responseCmd := sendInputResponseCmd (a .pendingInput .ResponseCh , output.InputResponse {SelectedKey : opt .Key })
315+ a .pendingInput = nil
316+ a .inputPrompt = a .inputPrompt .Hide ()
317+ return a , responseCmd
329318 }
330319 }
320+ if opt := resolveOption (a .pendingInput .Options , msg ); opt != nil {
321+ a .lines = appendLine (a .lines , styledLine {text : formatResolvedInput (* a .pendingInput , opt .Key )})
322+ responseCmd := sendInputResponseCmd (a .pendingInput .ResponseCh , output.InputResponse {SelectedKey : opt .Key })
323+ a .pendingInput = nil
324+ a .inputPrompt = a .inputPrompt .Hide ()
325+ return a , responseCmd
326+ }
327+ return a , nil
328+ }
331329
330+ func formatResolvedInput (req output.UserInputRequestEvent , selectedKey string ) string {
332331 formatted := output .FormatPrompt (req .Prompt , req .Options )
333332 firstLine := strings .Split (formatted , "\n " )[0 ]
334333
@@ -349,10 +348,6 @@ func formatResolvedInput(req output.UserInputRequestEvent, selectedKey string) s
349348 return fmt .Sprintf ("%s %s" , firstLine , selected )
350349}
351350
352- func componentsUsesVerticalPrompt (prompt components.InputPrompt , options []output.InputOption ) bool {
353- return prompt .Visible () && len (options ) > 1 && strings .Contains (options [0 ].Label , "[" )
354- }
355-
356351// resolveOption finds the best matching option for a key event, in priority order:
357352// 1. "any" — matches any keypress
358353// 2. "enter" — matches the Enter key explicitly
0 commit comments