Skip to content

feat: multi-cursor editing#14

Merged
eugenioenko merged 4 commits into
mainfrom
feat/multi-cursor
May 29, 2026
Merged

feat: multi-cursor editing#14
eugenioenko merged 4 commits into
mainfrom
feat/multi-cursor

Conversation

@eugenioenko
Copy link
Copy Markdown
Owner

Summary

  • Ctrl+D — select next occurrence of word/selection (incremental)
  • Ctrl+K L — select all occurrences at once
  • Alt+Click — add cursor at click position
  • Ctrl+K U — undo last cursor addition
  • Escape — collapse to single cursor
  • Type, backspace, delete, and enter work at all cursors simultaneously
  • All multi-cursor edits undo as a single step via BatchCommand
  • Status bar shows cursor count when multiple cursors active
  • Selection menu updated with new commands

New files

  • internal/core/multicursor/multicursor.go — MultiCursor data structure
  • internal/core/multicursor/multicursor_test.go — unit tests
  • internal/core/undo/undo_test.go — BatchCommand tests

Test plan

  • go test ./... — all 22 packages pass
  • make build — clean build
  • Manual: Ctrl+D on a word, repeat to select more occurrences, type replacement
  • Manual: Ctrl+K L to select all occurrences, type replacement
  • Manual: Alt+Click to place multiple cursors, type text
  • Manual: Ctrl+Z undoes multi-edit as one step
  • Manual: Escape collapses to single cursor
  • Manual: Ctrl+K U removes last added cursor

🤖 Generated with Claude Code

Add full multi-cursor support: select next/all occurrences, add cursors
via Alt+Click, type/delete/enter at all cursors simultaneously with
single-step undo via BatchCommand grouping.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
eugenioenko and others added 3 commits May 28, 2026 21:26
Two bugs prevented multi-cursor edits from working:

1. syncTabs() in Render() overwrote Editor.Multi on every redraw,
   losing cursor state set by SelectNextOccurrence(). Fixed by saving
   Multi back to the tab after mutations and after HandleEvent.

2. Cursor position adjustments went the wrong direction — adjusting
   unprocessed cursors (earlier positions) instead of already-processed
   ones (later positions). Rewrote adjust helpers to fix later-index
   cursors after each edit in the right-to-left loop.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use reverse style for all cursor positions so they appear as solid
blocks of the editor foreground color. Hide the hardware cursor when
multi-cursor is active so all cursors render uniformly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update README and docs-web with multi-cursor keybindings and behavior:
Ctrl+D, Ctrl+K L, Alt+Click, Ctrl+K U, Escape.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@eugenioenko eugenioenko merged commit 46967eb into main May 29, 2026
2 checks passed
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.

1 participant