moveWordBackward function
Implementation
int moveWordBackward(
List<String> graphemes,
int offset, {
required GraphemePredicate isWord,
}) {
if (offset <= 0 || graphemes.isEmpty) {
return 0;
}
var position = offset - 1;
while (position > 0 && !isWord(graphemes[position])) {
position--;
}
while (position > 0 && isWord(graphemes[position - 1])) {
position--;
}
return position.clamp(0, graphemes.length);
}