fix: remove the unnecessary operation in enter keyhandler

This commit is contained in:
Lucas.Xu 2022-10-29 15:16:31 +08:00
parent 43e4b1efad
commit 4a48a2af5a
2 changed files with 11 additions and 9 deletions

View File

@ -153,11 +153,13 @@ ShortcutEventHandler enterWithoutShiftInTextNodesHandler =
delta: textNode.delta.slice(selection.end.offset), delta: textNode.delta.slice(selection.end.offset),
), ),
); );
transaction.deleteText( if (selection.end.offset != textNode.toPlainText().length) {
textNode, transaction.deleteText(
selection.start.offset, textNode,
textNode.toPlainText().length - selection.start.offset, selection.start.offset,
); textNode.toPlainText().length - selection.start.offset,
);
}
if (textNode.children.isNotEmpty) { if (textNode.children.isNotEmpty) {
final children = textNode.children.toList(growable: false); final children = textNode.children.toList(growable: false);
transaction.deleteNodes(children); transaction.deleteNodes(children);

View File

@ -78,10 +78,10 @@ class AppFlowyRenderPlugin extends AppFlowyRenderPluginService {
node.key = key; node.key = key;
return _autoUpdateNodeWidget(builder, context); return _autoUpdateNodeWidget(builder, context);
} else { } else {
assert(false, // Returns a SizeBox with 0 height if no builder found.
'Could not query the builder with this $name, or nodeValidator return false.'); return const SizedBox(
// TODO: return a placeholder widget with tips. height: 0,
return Container(); );
} }
} }