moveCursorWordLeft method

void moveCursorWordLeft()

Moves cursor to the start of the previous word.

Implementation

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

  final graphemes = textBeforeCursor.characters.toList();
  var index = graphemes.length;
  while (index > 0 && graphemes[index - 1] == ' ') {
    index--;
  }
  while (index > 0 && graphemes[index - 1] != ' ') {
    index--;
  }
  _cursorPosition = graphemes.take(index).join().length;
}