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§
- Range
Edit - A minimal edit produced by
format_range: replacerange(byte offsets into the original source) withnew_text. Everything outsiderangeis unchanged.
Functions§
- format_
range - Reformat only the top-level statements intersecting
target(byte offsets intosource), leaving the rest of the document unchanged.