shiftRowsInRange method
void
shiftRowsInRange({})
Implementation
void shiftRowsInRange({
required int startLine,
required int endLine,
required int delta,
required int maxLine,
required int Function(int line) lineLength,
}) {
if (_cursor.line >= startLine && _cursor.line <= endLine) {
final nextLine = (_cursor.line + delta).clamp(0, maxLine);
_cursor = TextPosition(
line: nextLine,
column: _cursor.column.clamp(0, lineLength(nextLine)),
);
}
final currentSelection = _selection;
if (currentSelection == null) {
return;
}
_selection = TextSelection(
base: _shiftPositionRowRange(
currentSelection.base,
startLine: startLine,
endLine: endLine,
delta: delta,
maxLine: maxLine,
lineLength: lineLength,
),
extent: _shiftPositionRowRange(
currentSelection.extent,
startLine: startLine,
endLine: endLine,
delta: delta,
maxLine: maxLine,
lineLength: lineLength,
),
);
}