diff --git a/frontend/app_flowy/packages/flowy_editor/lib/src/document/text_delta.dart b/frontend/app_flowy/packages/flowy_editor/lib/src/document/text_delta.dart index 05f0d61b8d..658114df7a 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/src/document/text_delta.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/src/document/text_delta.dart @@ -417,7 +417,8 @@ class Delta extends Iterable { // 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(); } diff --git a/frontend/app_flowy/packages/flowy_editor/lib/src/operation/transaction_builder.dart b/frontend/app_flowy/packages/flowy_editor/lib/src/operation/transaction_builder.dart index dfca3cd661..68a46d8a93 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/src/operation/transaction_builder.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/src/operation/transaction_builder.dart @@ -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); } diff --git a/frontend/app_flowy/packages/flowy_editor/lib/src/service/internal_key_event_handlers/enter_without_shift_in_text_node_handler.dart b/frontend/app_flowy/packages/flowy_editor/lib/src/service/internal_key_event_handlers/enter_without_shift_in_text_node_handler.dart index 39c74d2eab..1a25a2531d 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/src/service/internal_key_event_handlers/enter_without_shift_in_text_node_handler.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/src/service/internal_key_event_handlers/enter_without_shift_in_text_node_handler.dart @@ -86,7 +86,7 @@ FlowyKeyEventHandler enterWithoutShiftInTextNodesHandler = ); TransactionBuilder(editorState) ..insertNode( - textNode.path, + textNode.path.next, TextNode.empty(), ) ..afterSelection = afterSelection