moveCursorWordLeft method

void moveCursorWordLeft()

Moves cursor to the start of the previous word.

Implementation

void moveCursorWordLeft() {
  if (_cursorPosition == 0) return;

  final t = text;
  var pos = _cursorPosition - 1;

  // Skip whitespace
  while (pos > 0 && t[pos] == ' ') {
    pos--;
  }

  // Find start of word
  while (pos > 0 && t[pos - 1] != ' ') {
    pos--;
  }

  _cursorPosition = pos;
}