Fix vertical cursor movement at wrap boundaries #80

Closed
jessegrosjean wants to merge 1 commit from fix-vertical-cursor-wrap-boundary into main
jessegrosjean commented 2026-03-11 17:39:39 +01:00 (Migrated from github.com)

Summary

  • When extending a non-empty selection vertically at a wrap boundary, the default assoc could resolve the head position to the wrong visual line, causing the selection to not move or overshoot. This tries the alternate assoc and picks the result with minimal forward progress.
  • Fixes posAtCoords to find the position at the goal X on the first/last line during vertical motion, instead of ignoring X and returning position 0 or doc.length.
  • Uses lineHeight instead of textHeight for the vertical step distance, and adds a fallback to the document boundary when posAtCoords returns the same position (so select commands can extend to start/end).

Test plan

  • Tests are in the companion PR to codemirror/commands
  • Verified with node bin/cm.js test in the dev monorepo (all tests pass, only pre-existing bidi failures remain)
  • Includes a fuzzing harness that randomly executes cursor/select line commands and verifies directional progress and reversibility

🤖 Generated with Claude Code

## Summary - When extending a non-empty selection vertically at a wrap boundary, the default `assoc` could resolve the head position to the wrong visual line, causing the selection to not move or overshoot. This tries the alternate assoc and picks the result with minimal forward progress. - Fixes `posAtCoords` to find the position at the goal X on the first/last line during vertical motion, instead of ignoring X and returning position 0 or `doc.length`. - Uses `lineHeight` instead of `textHeight` for the vertical step distance, and adds a fallback to the document boundary when `posAtCoords` returns the same position (so select commands can extend to start/end). ## Test plan - Tests are in the companion PR to `codemirror/commands` - Verified with `node bin/cm.js test` in the dev monorepo (all tests pass, only pre-existing bidi failures remain) - Includes a fuzzing harness that randomly executes cursor/select line commands and verifies directional progress and reversibility 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/view!80
No description provided.