moveMultiCursorsLeft method

void moveMultiCursorsLeft({
  1. bool isShiftPressed = false,
})

Moves every secondary cursor one character to the left.

When isShiftPressed is true the secondary cursors are cleared because extending a multi-cursor selection is not supported.

Implementation

void moveMultiCursorsLeft({bool isShiftPressed = false}) {
  if (_multiCursors.isEmpty) return;
  if (isShiftPressed) {
    clearMultiCursors();
    return;
  }
  final updated = <({int line, int character})>[];
  for (final cursor in _multiCursors) {
    final offset = _multiCursorToOffset(cursor);
    final newOffset = (offset - 1).clamp(0, _rope.length);
    final newLine = _rope.getLineAtOffset(newOffset);
    final newLineStart = _rope.getLineStartOffset(newLine);
    updated.add((line: newLine, character: newOffset - newLineStart));
  }
  _updateMultiCursorsFromList(updated);
}