deleteForward method
Deletes forward from the cursor or removes the current selection.
Implementation
bool deleteForward({bool word = false, bool coalesce = false}) {
return _runEditFrame(() {
final hasSelection =
selectionStart != null &&
selectionEnd != null &&
selectionStart != selectionEnd;
final action = hasSelection
? _TextInputHistoryAction.replace
: _TextInputHistoryAction.deleteForward;
_beginHistoryAction(
action,
breakChain: !coalesce || action == _TextInputHistoryAction.replace,
);
_resetDesiredCol();
if (_deleteSelection()) {
_updateSuggestions();
_handleOverflow();
return true;
}
final before = _captureEditState();
if (word) {
_deleteWordForward();
} else {
final result = textDeleteNext(
document: _document,
state: _currentOffsetStateSnapshot(),
);
if (result.changed) {
_recordUndoSnapshot();
_applyEditCommandResult(result);
}
}
_updateSuggestions();
_handleOverflow();
return !before.sameAs(_captureEditState());
});
}