textCleanupWhitespaceDocument function
TextCommandResult
textCleanupWhitespaceDocument({
- required TextDocument document,
- required TextLineStateSnapshot state,
- bool trimTrailingBlankLines = true,
Implementation
TextCommandResult textCleanupWhitespaceDocument({
required TextDocument document,
required TextLineStateSnapshot state,
bool trimTrailingBlankLines = true,
}) {
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) => textCleanupWhitespace(
lines: lines,
state: localState,
trimTrailingBlankLines: trimTrailingBlankLines,
),
);
}