Skip to main content

tree_levels_for_new_line

Function tree_levels_for_new_line 

Source
pub fn tree_levels_for_new_line(
    snapshot: &SyntaxSnapshot,
    at: usize,
) -> Option<i32>
Expand description

Indent level, in steps, for a new line inserted at byte at.

Counts the @indent nodes that are genuinely open at at: start_byte < at < end_byte. Both bounds are strict, and the upper one matters — with at <= end_byte, a cursor sitting just past a block’s closing brace (fn f() {}|) would still count the block and indent the next line by one.

Returns None when there is no tree or no query for the language, which is the caller’s signal to use the lexical bridge.