Skip to main content

format_range

Function format_range 

Source
pub fn format_range(
    source: &str,
    config: &FmtConfig,
    sel: Range<usize>,
) -> Option<RangeEdit>
Expand description

Format only the part of source overlapping the byte range sel (for editor “format selection” / LSP textDocument/rangeFormatting). The whole document is formatted for correct structure and indentation; the result is the minimal changed line-hunk that intersects sel, or None if nothing in the selection’s lines changes. Applying the edit yields the same bytes the whole-file [format] would have produced for that region.