Skip to content

feat(editor): add neovim-style mouse selection - #363

Merged
fcoury merged 1 commit into
mainfrom
fcoury/mouse-visual-selection
Sep 12, 2026
Merged

fcoury merged 1 commit into
mainfrom
fcoury/mouse-visual-selection

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Mouse clicks positioned the cursor, but dragging did not select text. Left dragging now creates an inclusive Visual selection that remains active after release and works with y, d, c, keyboard motions and gv.

  • Map pointer positions through the rendered layout for tabs, Unicode, wrapping, scrolling and line endings.
  • Keep gestures in their originating split, autoscroll while held outside the viewport, and cancel capture on release, focus loss, resize or client disconnect. Completed selections remain available after reconnecting.
  • Add word/delimiter, line and block selection through multiple clicks, Alt blocks and Shift extension. Preserve Insert-mode restoration and undo boundaries.

How to Test

  1. Open a file containing alpha beta gamma. Drag across beta and release: it should remain highlighted in Visual mode. Press y, run :enew, then p: the new buffer should contain exactly beta.
  2. Create a vertical split and drag from text in one window across the divider. Selection should stay in the source window. Press Escape, then start a new gesture on the divider: it should resize normally.
  3. In a long file, hold a drag below the text viewport. Selection should extend as the viewport scrolls; release or focus loss should stop scrolling.
  4. Run cargo test --test editing mouse_selection_ and cargo test --test mouse_selection_detached for selection, Insert undo, coordinate mapping and disconnected-client regressions.

Validation

  • Full integration run: 468 editing and 30 detached-target tests passed, including the existing 2 MiB stack regression.
  • Final focused run: all 26 mouse-selection tests passed, including three added after the full run.
  • All 14 library mouse-routing tests passed; formatting and cargo clippy --all-targets --all-features -- -D warnings passed. The committed source matches the validated files.
  • Runtime checks through tmux verified release, exact yank, autoscroll, Unicode, wrapping, split ownership, divider resizing and attached-client reconnection. These injected SGR mouse reports through a real PTY. Physical dragging in direct Ghostty remains unverified.

Modifier gestures depend on terminal delivery; terminal-native selection and Neovim's right-click popup behavior are outside this implementation. The reattached client's :q! cleanup reported a broken pipe after the selection checks passed, so clean attached shutdown is not claimed here.

@fcoury
fcoury merged commit 9e09527 into main Sep 12, 2026
13 checks passed
@fcoury
fcoury deleted the fcoury/mouse-visual-selection branch September 12, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants