Skip to main content

apply_fold_level_to_new

Function apply_fold_level_to_new 

Source
pub fn apply_fold_level_to_new(folds: &mut [Fold], carried: &[bool], level: u32)
Expand description

Close new folds that sit deeper than foldlevel, leaving folds whose state was carried over untouched.

carried[i] is true when folds[i] inherited its closed flag from a previous fold with the same identity. Those keep whatever the user last did to them; the rest are new structure, and new structure obeys the option.

Only ever closes. A provider may emit a fold already closed — diff-mode’s unchanged-region folds are the in-tree case, and the whole point of them is that the unchanged stretches start collapsed. Assigning closed = depth > level here rather than OR-ing reopened every one of them at the default level, because a level-1 fold is not deeper than 99. foldlevel decides whether nesting depth adds a close; it does not get a vote on a provider’s own intent. Reopening is the bulk apply_fold_level path, which is a user action.