Skip to main content

word_boundaries

Function word_boundaries 

pub fn word_boundaries(text: &str, byte_idx: usize) -> (usize, usize)
Expand description

Byte range (start, end) of the UAX #29 word containing byte_idx, or the word immediately on the left when the index lands in following punctuation or whitespace. Used by double-click word selection.

Words never cross a line feed (UAX #29 breaks on both sides of one), so only the index’s own line is segmented; earlier lines are segmented, one at a time, only when this line has no word up to the index.