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