Skip to main content

sentence_bounds

Function sentence_bounds 

Source
pub fn sentence_bounds(
    text: &str,
    char_offset: usize,
    locale: Option<&str>,
) -> Option<(usize, usize)>
Expand description

The sentence of text containing char_offset, as block-relative char offsets, with trailing whitespace trimmed off the end so a highlight stops at the terminator rather than trailing into the gap before the next sentence.

None when text holds no sentence to point at (empty, or whitespace only).

char_offset may sit at the very end of text, which resolves to the last sentence — the caret is after the final character, exactly as find_word_boundaries treats the end of the last word.