feat: filter the empty delta

This commit is contained in:
Vincent Chan 2022-08-12 18:03:22 +08:00
parent 0424c14c7d
commit ba05aa137e
3 changed files with 6 additions and 2 deletions

View File

@ -417,7 +417,8 @@ class Delta extends Iterable<TextOperation> {
// Optimization if rest of other is just retain
if (!otherIter.hasNext &&
delta._operations[delta._operations.length - 1] == newOp) {
delta._operations.isNotEmpty &&
delta._operations.last == newOp) {
final rest = Delta(thisIter.rest());
return (delta + rest)..chop();
}

View File

@ -203,6 +203,9 @@ class TransactionBuilder {
for (var i = 0; i < operations.length; i++) {
op = transformOperation(operations[i], op);
}
if (op is TextEditOperation && op.delta.isEmpty) {
return;
}
operations.add(op);
}

View File

@ -86,7 +86,7 @@ FlowyKeyEventHandler enterWithoutShiftInTextNodesHandler =
);
TransactionBuilder(editorState)
..insertNode(
textNode.path,
textNode.path.next,
TextNode.empty(),
)
..afterSelection = afterSelection