Skip to main content

compute_indent_folds

Function compute_indent_folds 

Source
pub fn compute_indent_folds(buffer: &Buffer, unit: &IndentUnit) -> Vec<Fold>
Expand description

Run the indent-based fold algorithm against buffer and return every fold it discovers. All produced folds are open (closed = false) by default – vim’s foldlevelstart would override that, but v1 doesn’t model the level option yet.

The walk itself lives in lattice_core::indent_blocks::indent_regions, shared with indentation guides. A fold and a guide answer the same question – what block is this line in – and a user who folds a block and sees a different extent than the one just highlighted has been told two different things by the same editor.

IG.5: depth is display columns now, not leading whitespace characters. The leading_indent this replaced counted a tab as one column, so a tab-indented file folded at different boundaries than its space-indented twin – the refinement the old doc comment promised “when we honour tabstop / shiftwidth”. unit supplies that, resolved through the buffer-local stack like every other indent consumer.

The output is sorted by start_line; nested folds appear inside their parent’s range.