Expand description
Caret movement — the motions and the two combinators that apply them to a
SelectionSet.
Motions are pure functions of the buffer and a position; the combinator
move_selections maps one over every selection, either moving (collapse
to a caret) or extending (drag the head, anchor fixed). Two details worth
knowing: a plain horizontal move over a non-empty selection collapses to its
near edge (not one char further), and vertical motion carries a goal
column so travelling across short lines returns to the original column —
the affinity editors are judged on.
Horizontal positions here are byte columns, but the vertical goal is a display cell: the caret keeps its visual column through tab stops, collapsed inline folds, and collapsed block placeholders, resolved on landing by the same inverse projection a mouse click uses.
Enums§
- Column
Dir - A direction for column (box) selection — Ctrl+Shift+Alt+Arrow. Up/ Down move the active row; Left/Right move the active (virtual) column.
- Granularity
- Drag/selection granularity — the unit a click-drag extends by: single characters, whole words, or whole lines.
- Motion
- A caret motion.
Functions§
- move_
selections - Apply
motionto every selection inset. Withextend, each selection’s head moves and its anchor stays (grow/shrink); without, each collapses to a caret at the motion target. Re-merges afterward (a move can make two selections coincide).tabis the document’s tab-stop width — vertical motion keeps a visual goal column, so it needs the display projection.