Skip to main content

expand_line_range_to_blocks

Function expand_line_range_to_blocks 

Source
pub fn expand_line_range_to_blocks(
    tree: &SyntaxNode,
    text: &str,
    start_line: usize,
    end_line: usize,
) -> Option<(usize, usize)>
Expand description

Expand a 1-indexed line range to encompass complete block-level elements.

This is the public API for range formatting. It converts line numbers to byte offsets, expands to block boundaries, and returns the expanded byte range.

§Arguments

  • tree - The syntax tree root
  • text - The original document text
  • start_line - Starting line number (1-indexed, inclusive)
  • end_line - Ending line number (1-indexed, inclusive)

§Returns

Expanded byte range (start, end) that covers complete blocks, or None if range is invalid