Alt-click (Option-click) to position cursor in prompt input
Feature Request
Alt-click (Option-click on macOS) should move the text cursor to the clicked position in the prompt input, matching the behavior users expect from ZSH and other terminal emulators.
Motivation
In ZSH (and most modern terminals), users can Option-click (or Alt-click on Linux) anywhere in the current command line to instantly reposition the cursor there. This is a deeply ingrained muscle-memory interaction for terminal power users. Claude Code's prompt input currently does not support this, forcing users to rely solely on arrow keys or Home/End to navigate within their prompt text — which is slow and frustrating, especially for longer prompts.
Expected Behavior
- User holds Alt (or Option on macOS) and clicks at a position within the prompt text
- The text cursor (
cursorOffset) moves to the character position closest to where the user clicked - No text is selected or modified — only the cursor position changes
Technical Notes
The existing codebase already has much of the infrastructure needed:
- Mouse tracking modes are supported (
MOUSE_NORMAL,MOUSE_BUTTON,MOUSE_ANY) in the terminal renderer - SGR mouse event parsing is implemented for decoding mouse click coordinates
- The text input component exposes
cursorOffsetand anonChangeCursorOffsetcallback
The main gap is that alt-modified mouse click events are not currently wired to update cursorOffset in the prompt input component. The implementation would involve:
- Detecting an alt-modified mouse-down event in the input area
- Mapping the click's
(column, row)coordinates to a character offset within the rendered prompt text - Calling
onChangeCursorOffsetwith the computed offset
Precedent
- ZSH (with default key bindings): Option-click repositions cursor
- iTerm2: Option-click moves cursor in shell prompt
- macOS Terminal.app: Option-click moves cursor in shell prompt
- VS Code integrated terminal: Alt-click moves cursor
This is a standard terminal UX convention that Claude Code users would benefit from.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗