pub fn shift_fold(
fold: Fold,
edit_start: usize,
drop_end: usize,
shift_threshold: usize,
delta: isize,
) -> Option<Fold>Expand description
Shift a single fold’s start_row / end_row by an edit’s row-delta band.
Returns None when the edit’s deleted band fully consumes the fold.
Each endpoint is mapped independently through the same drop/shift rule
crate::buffer::View::rebase_marks applies to a point mark. Mapping
the two endpoints independently is what produces the vim-shaped “edit
inside a fold” semantics for free:
- Both endpoints below
shift_thresholdand outside the deleted band → fold untouched (edit happened entirely outside the fold). start_rowoutside the deleted band butend_rowinside it → the edit deleted the fold’s tail; it clips to end at the last surviving row (edit_start - 1).start_rowinside the deleted band butend_rowoutside it → the edit deleted the fold’s head; it clips to start atedit_start(the row the surviving tail now occupies).- Both endpoints inside the deleted band → the edit consumed the whole fold; it’s dropped.
start_rowbelow the threshold andend_rowat/above it (an insert or a deletion landing strictly inside the fold) →start_rowstays,end_rowshifts bydelta: the fold grows (insert) or shrinks (delete) around the edit, matching vim.- Both endpoints at/above the threshold → the fold shifts wholesale.