Skip to main content

Module verbs

Module verbs 

Source
Expand description

The editing verbs: type, backspace, delete, enter, paste, (out)dent, and move / copy line. Each turns the current selections into one atomic multi-range transaction, then places a caret after each edit — so every verb is multi-cursor-correct for free (one op per selection). The placement is handed to the commit itself (Document::edit_placing), never assigned once the edit returns, so history records it as the unit’s after-selections and redo restores exactly the carets the verb left.

The one catch is deletion: a selection’s delete can reach past its neighbour (a tab-stop backspace, a word, a line block), so delete verbs merge their ranges first (merge_delete_ranges) — the engine rejects overlapping ops — and every verb commits through verb_commit, which turns an overlap that slipped through into a debug panic instead of a keystroke that silently does nothing.

Two load-bearing semantics live here: typing over a selection replaces it (one transaction, caret after), and Enter’s autoindent is the leading whitespace truncated to the caret column (never duplicated) — plus the two brace rules (one unit deeper after a line-opening {; {|} splits onto three lines), always computed for inserted text only, never re-indenting existing lines, so autoindent cannot fight the user. Clipboard text is normalized to LF on the way in; the LF→OS-flavor re-expansion for copy-out lives in the widget layer.

Functions§

default_indent_size
Spaces per indent level: the stop spacing Tab, Shift+Tab, the block (out)dent and backspace’s tab-stop delete use on a space-indented line (a tab-indented line moves by one hard tab instead).