textSortSelectedLinesDocument function
TextCommandResult
textSortSelectedLinesDocument({
- required TextDocument document,
- required TextLineStateSnapshot state,
- bool descending = false,
- bool caseSensitive = false,
Implementation
TextCommandResult textSortSelectedLinesDocument({
required TextDocument document,
required TextLineStateSnapshot state,
bool descending = false,
bool caseSensitive = false,
}) {
final clampedState = _clampLineStateSnapshotToDocument(state, document);
final hasSelection = clampedState.hasSelection;
final span = hasSelection
? _selectedLineSpan(clampedState)
: (startLine: 0, endLine: document.lineCount - 1);
return _documentResultFromWindowedLineCommand(
document: document,
state: clampedState,
startLine: span.startLine,
endLine: span.endLine + 1,
apply: (lines, localState) => textSortSelectedLines(
lines: lines,
state: localState,
descending: descending,
caseSensitive: caseSensitive,
),
);
}