Expand description
Selections and the multi-cursor set.
A Selection is a byte-offset range with a direction: start <= end
always, and reversed says which end the caret (the head) is on, so the
set is always stored in document order while the caret can face either way.
Empty selections (start == end) are bare carets.
A SelectionSet holds one or more disjoint selections, kept sorted and
merged. Multi-cursor is a first-class model concept: the gestures that add
cursors live in the UI layer, and this is the data they act on. Selections
rebase through every edit’s Patch eagerly, so a caret is always the
current position and never a stale copy of an offset from before the edit.
Structs§
- Selection
- A directional byte-offset range.
start <= endis an invariant;reversedrecords whether the caret is atstart(true) orend(false). - Selection
Id - Identity for a selection, monotonic within a
SelectionSet. Larger ids are newer; used to pick the newest (autoscroll target) and oldest (Escape). - Selection
Set - A non-empty, sorted, disjoint set of selections. Merged after every mutation so no two selections overlap.