pub fn shift_position(
p: Position,
edit: &Edit,
line_len: impl Fn(usize) -> usize,
rows: usize,
) -> Option<Position>Expand description
Rewrite p so it still points at the same text after edit lands, or
None when the edit’s geometry is not modelled and the position must be
dropped rather than guessed.
line_len returns the pre-edit char length of a row, and rows the
pre-edit row count. Only the row-restructuring edits consult them.
§Units
Works in char columns, which is what Edit and View::cursor both
speak. Deliberately not expressed over crate::types::Selection, whose
Pos::col counts graphemes: doing this arithmetic in grapheme columns
would silently mis-shift every position sitting after a multi-byte
character. Converting between the two units needs the buffer, so it belongs
at the call boundary, not here.