applyColumnDeltas method

void applyColumnDeltas(
  1. Map<int, int> deltas, {
  2. required int lineLength(
    1. int line
    ),
})

Implementation

void applyColumnDeltas(
  Map<int, int> deltas, {
  required int Function(int line) lineLength,
}) {
  if (deltas.isEmpty) {
    return;
  }

  final cursorDelta = deltas[_cursor.line];
  if (cursorDelta != null) {
    _cursor = TextPosition(
      line: _cursor.line,
      column: (_cursor.column + cursorDelta).clamp(
        0,
        lineLength(_cursor.line),
      ),
    );
  }

  final currentSelection = _selection;
  if (currentSelection == null) {
    return;
  }

  _selection = TextSelection(
    base: _shiftPositionByColumnDelta(
      currentSelection.base,
      deltas,
      lineLength: lineLength,
    ),
    extent: _shiftPositionByColumnDelta(
      currentSelection.extent,
      deltas,
      lineLength: lineLength,
    ),
  );
}