pub fn oneshot_highlight_lines(
lang: Lang,
registry: Arc<LangRegistry>,
source: &str,
start_line: u32,
end_line: u32,
) -> Option<Vec<Vec<StyledSpan>>>Expand description
Run a fresh tree-sitter parse over source and return
per-line styled spans for lines in start_line..end_line.
Returns None when:
langisLang::Plain(no grammar to apply),- the registry has no registered grammar for
lang, - the parse or highlight call fails for any reason (registry lookup error, malformed source, etc.) — fail silently so the caller’s “no syntax” fallback path (monochrome rendering) takes over without a panic.
start_line and end_line are inclusive-exclusive in
line indices, matching
crate::SyntaxSnapshot::highlight_lines. Returns one
Vec<StyledSpan> per line in the range. Spans within
each inner vec are line-relative byte offsets.
Cost model. Tree-sitter parse is O(source_len);
highlight query walk is O(matches). For the diff
deletion-block case where a typical baseline is hundreds
to thousands of lines, both are well under 10 ms on
modern hardware — within
DiffOverlayRefreshTask’s off-thread budget. Caller is
expected to invoke at hunk-publish frequency (debounced
at the session level), not per-frame.