pub fn indent_regions(lines: &[LineIndent]) -> Vec<IndentRegion>Expand description
Walk lines and emit every indent region, ordered by opener line.
A region opens at line p when the next non-blank line is strictly deeper
than p, and closes at the first non-blank line no deeper than p — with
that line swallowed when it is a closer at exactly p’s
depth. Blank lines are transparent throughout: they neither break a region
nor extend one past its last content line.
Linear in lines.len(): a stack of open regions, popped when a line closes
them. The direct transcription of the “walk forward to find the end”
formulation is quadratic on deeply nested files, and this runs on every
publish.