textMoveSelectedLinesDocument function
TextCommandResult
textMoveSelectedLinesDocument({
- required TextDocument document,
- required TextLineStateSnapshot state,
- required int direction,
Implementation
TextCommandResult textMoveSelectedLinesDocument({
required TextDocument document,
required TextLineStateSnapshot state,
required int direction,
}) {
final clampedState = _clampLineStateSnapshotToDocument(state, document);
final span = _selectedLineSpan(clampedState);
final startLine = direction < 0
? math.max(0, span.startLine - 1)
: span.startLine;
final endLine = direction > 0
? math.min(document.lineCount, span.endLine + 2)
: span.endLine + 1;
return _documentResultFromWindowedLineCommand(
document: document,
state: clampedState,
startLine: startLine,
endLine: endLine,
apply: (lines, localState) => textMoveSelectedLines(
lines: lines,
state: localState,
direction: direction,
),
);
}