mergeWith method
Merge this operation with another
Implementation
@override
EditOperation mergeWith(EditOperation other) {
if (other is! DeleteOperation) return this;
if (other.offset == offset - other.text.length) {
return DeleteOperation(
offset: other.offset,
text: other.text + text,
selectionBefore: selectionBefore,
selectionAfter: other.selectionAfter,
timestamp: other.timestamp,
);
}
if (other.offset == offset) {
return DeleteOperation(
offset: offset,
text: text + other.text,
selectionBefore: selectionBefore,
selectionAfter: other.selectionAfter,
timestamp: other.timestamp,
);
}
return this;
}