Skip to main content

highlight

Function highlight 

Source
pub fn highlight(
    lines: &[Line],
    ranges: &[Range<usize>],
    restyle: impl Fn(Style) -> Style,
) -> Vec<Line>
Expand description

Restyles the text inside ranges, for a search match or a word-level diff; text, widths and links never change.

Ranges are char offsets into the lines’ plain text joined with no separator, lines.iter().map(Line::plain).collect::<String>(), in any order; overlapping ones restyle once. A span is split where a range starts or ends inside it.