textMoveByCharacter function
TextCursorCommandResult
textMoveByCharacter({
- required TextDocument document,
- required TextOffsetStateSnapshot state,
- required bool forward,
- bool extendSelection = false,
- bool clearSelection = false,
Implementation
TextCursorCommandResult textMoveByCharacter({
required TextDocument document,
required TextOffsetStateSnapshot state,
required bool forward,
bool extendSelection = false,
bool clearSelection = false,
}) {
final targetOffset = forward
? (state.cursorOffset + 1).clamp(0, document.length)
: (state.cursorOffset - 1).clamp(0, document.length);
return moveCursorToOffset(
textLength: document.length,
cursorOffset: state.cursorOffset,
selectionBaseOffset: state.selectionBaseOffset,
selectionExtentOffset: state.selectionExtentOffset,
targetOffset: targetOffset,
extendSelection: extendSelection,
clearSelection: clearSelection,
);
}