Skip to main content

find_prev_word_start

Function find_prev_word_start 

Source
pub fn find_prev_word_start(text: &Rope, cursor_byte: usize) -> usize
Expand description

Finds the start offset of the previous word (or punctuation token) moving backward from cursor_byte.

Behavior matches classic editor Ctrl + Left:

  1. If preceded by whitespace (non-newline), skips backward across the whitespace.
  2. If preceded by a newline, stops at that line boundary.
  3. Identifies whether the preceding token is a word or punctuation sequence.
  4. Moves backward across consecutive characters of that same kind.
  5. Returns the starting byte offset of that token.