Skip to content

HOME/END should navigate to start/end of visual line on wrapped input, with Ctrl modifier for logical boundaries #22008

@ddiall

Description

@ddiall

Summary

In the TUI TextInput, pressing moves cursor to position 0 (start of the entire input) and to v.length (end of the entire input). For a single long prompt that wraps across multiple terminal lines, this ignores the visual line the cursor is on.

Expected Behavior

  • First <Home>: snap cursor to start of the current visual line (the line as it appears on screen)
  • Second <Home> (press again): snap to logical start (position 0)
  • First <End>: snap cursor to end of the current visual line
  • Second <End> (press again): snap to logical end (v.length)
  • Ctrl+Home: always go to logical start (absolute position 0)
  • Ctrl+End: always go to logical end (absolute v.length)

Technical Notes

The infrastructure already exists:

  • cursorLayout() in ui-tui/src/lib/inputMetrics.ts computes the current visual line given terminal width
  • visualLines() returns start/end boundaries of each visual line
  • The fix lives in ui-tui/src/components/textInput.tsx (~lines 796-808 currently)

A similar approach is used by GNU Readline and most modern TUIs (e.g., Textual, Bubble Tea).

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/tuiTerminal UI (ui-tui/ + tui_gateway/)type/featureNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions