moveCursorToVisualLineBoundary function

TextCursorCommandResult moveCursorToVisualLineBoundary(
  1. TextDocument document,
  2. EditorState state,
  3. TextView view, {
  4. required int cursorOffset,
  5. int? selectionBaseOffset,
  6. int? selectionExtentOffset,
  7. required bool end,
  8. bool extendSelection = false,
  9. bool clearSelection = true,
  10. bool preserveCollapsedSelection = false,
})

Implementation

TextCursorCommandResult moveCursorToVisualLineBoundary(
  TextDocument document,
  EditorState state,
  TextView view, {
  required int cursorOffset,
  int? selectionBaseOffset,
  int? selectionExtentOffset,
  required bool end,
  bool extendSelection = false,
  bool clearSelection = true,
  bool preserveCollapsedSelection = false,
}) {
  final cursor = document.positionForOffset(
    cursorOffset.clamp(0, document.length),
  );
  final targetOffset = view.cursorOffsetForVisualLineBoundary(
    document,
    state,
    end: end,
    cursor: cursor,
  );

  return moveCursorToOffset(
    textLength: document.length,
    cursorOffset: cursorOffset,
    selectionBaseOffset: selectionBaseOffset,
    selectionExtentOffset: selectionExtentOffset,
    targetOffset: targetOffset,
    extendSelection: extendSelection,
    clearSelection: clearSelection,
    preserveCollapsedSelection: preserveCollapsedSelection,
  );
}