Skip to main content

Module range

Module range 

Source
Expand description

Statement-level range formatting.

Whole-document formatting reflows everything; range formatting reflows only the top-level statements that intersect a caller-supplied byte range and leaves the rest of the document byte-for-byte unchanged. This mirrors editor “Format Selection” and an LSP rangeFormatting request, and is built on the same lossless CST as crate::format.

The unit of work is a whole statement: a statement is reformatted if the range touches any of it. The returned RangeEdit replaces the span from the first selected statement’s first significant token through the last selected statement’s terminating semicolon, so leading blank lines and same-line trailing comments around the selection are preserved exactly.

Structs§

RangeEdit
A minimal edit produced by format_range: replace range (byte offsets into the original source) with new_text. Everything outside range is unchanged.

Functions§

format_range
Reformat only the top-level statements intersecting target (byte offsets into source), leaving the rest of the document unchanged.