Expand description
Indent blocks — the shared answer to “what block is this line in”.
IndentUnit answers how wide is one level.
This module answers where do the levels begin and end, and it has two
consumers that must not disagree:
- Indentation guides — a guide is a block’s column drawn down the
block’s extent (
docs/dev/architecture/indent-guides.md). foldmethod=indent— a fold is a block’s extent (lattice-host/src/folds.rs).
They are two views of one question, and a user who folds a block and sees a different extent than the one that was just highlighted has been told two different things by the same editor. So the walk lives here, once, and both call it.
Nothing here reads config or touches a rope: line_indents projects lines
to LineIndent, and indent_blocks is a pure function of that
projection. That is what lets the subtle cases — blank runs, closer
inclusion, multi-level jumps, tabs — be argued against a unit test rather
than against a screenshot.
Structs§
- Indent
Block - One indent guide: a display column, and the inclusive line range it spans.
- Indent
Region - A contiguous region of indented lines: everything between an opener and its closer.
- Line
Indent - One line’s contribution to the block walk.
- Line
Shape - The only three facts the indent-guide builder needs about a line,
in a
Copystruct so it can be produced without materialising the line’s text.
Functions§
- indent_
blocks - Expand every region into one guide per grid column it spans.
- indent_
regions - Walk
linesand emit every indent region, ordered by opener line. - is_
closer_ line - Whether
lineis a pure closing-bracket line. - line_
indents - Project lines to the walk’s input.