Skip to main content

prev_word_boundary

Function prev_word_boundary 

Source
pub fn prev_word_boundary(text: &str, from: usize) -> usize
Expand description

Byte offset of the start of the Unicode-word segment strictly before from. Used for directional word motion (ctrl+<-, ctrl+Backspace) - shares the split_word_bound_indices walk select_word_at_byte uses to expand a point into a range, but returns the boundary itself rather than a (start, end) pair.

Whitespace runs count as their own segment (matching unicode-segmentation’s word-boundary rules), so repeated calls step through a text one word or one whitespace run at a time - the same granularity lumen-text-edit’s CursorMotion::WordLeft uses.