delete method
void
delete()
Remove the selection or the char at cursor position (delete key)
Implementation
void delete() {
if (_undoController?.isUndoRedoInProgress ?? false) return;
_flushBuffer();
final selectionBefore = _selection;
final sel = _selection;
final textLen = _rope.length;
String deletedText;
if (sel.start < sel.end) {
deletedText = _rope.substring(sel.start, sel.end);
_rope.delete(sel.start, sel.end);
_currentVersion++;
_selection = TextSelection.collapsed(offset: sel.start);
dirtyLine = _rope.getLineAtOffset(sel.start);
_recordDeletion(sel.start, deletedText, selectionBefore, _selection);
} else if (sel.start < textLen) {
deletedText = _rope.charAt(sel.start);
_rope.delete(sel.start, sel.start + 1);
_currentVersion++;
dirtyLine = _rope.getLineAtOffset(sel.start);
_recordDeletion(sel.start, deletedText, selectionBefore, _selection);
} else {
return;
}
_syncToConnection();
notifyListeners();
}