cleanupWhitespace method
Cleans up trailing horizontal whitespace in the selected block, or the entire buffer when there is no selection.
When operating on the entire buffer, this also removes extra trailing blank lines from the end of the document while keeping at least one line.
Implementation
bool cleanupWhitespace({bool trimTrailingBlankLines = true}) {
return _runEditFrame(() {
_beginHistoryAction(_TextAreaHistoryAction.transform, breakChain: true);
final result = textCleanupWhitespaceDocument(
document: _document,
state: _currentLineStateSnapshot(),
trimTrailingBlankLines: trimTrailingBlankLines,
);
if (!result.changed) {
return false;
}
_recordUndoSnapshot();
_applyOffsetCommandResult(result);
return true;
});
}