Skip to main content

shift_sel

Function shift_sel 

Source
pub fn shift_sel(
    sel: Sel,
    edit: &Edit,
    line_len: impl Fn(usize) -> usize,
    rows: usize,
) -> Option<Sel>
Expand description

Rewrite BOTH ends of sel so it still covers the same text after edit, or None when either end is untrackable.

All-or-nothing is the whole point: a selection whose head survived and whose anchor did not is worse than no selection at all — it would still apply the next edit, just over a range the user never selected. Half-tracked is not a state this type can be in.

See shift_position for the contract on line_len / rows (both are pre-edit geometry).