From e94eb20388d52e620833c984e63b61f728974222 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Fri, 9 Dec 2022 11:06:28 +0800 Subject: [PATCH] chore: disable rules for test cases --- .../packages/appflowy_editor/lib/src/editor_state.dart | 10 +++++++--- .../appflowy_editor/test/infra/test_editor.dart | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/editor_state.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/editor_state.dart index 361dfb742f..be49ea19d0 100644 --- a/frontend/app_flowy/packages/appflowy_editor/lib/src/editor_state.dart +++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/editor_state.dart @@ -73,6 +73,7 @@ class EditorState { // TODO: only for testing. bool disableSealTimer = false; + bool disbaleRules = false; bool editable = true; @@ -124,6 +125,7 @@ class EditorState { Transaction transaction, { ApplyOptions options = const ApplyOptions(recordUndo: true), ruleCount = 0, + withUpdateCursor = true, }) { if (!editable) { return; @@ -137,7 +139,9 @@ class EditorState { WidgetsBinding.instance.addPostFrameCallback((_) { _applyRules(ruleCount); - updateCursorSelection(transaction.afterSelection); + if (withUpdateCursor) { + updateCursorSelection(transaction.afterSelection); + } }); if (options.recordUndo) { @@ -187,7 +191,7 @@ class EditorState { void _applyRules(int ruleCount) { // Set a maximum count to prevent a dead loop. - if (ruleCount >= 5) { + if (ruleCount >= 5 || disbaleRules) { return; } @@ -197,7 +201,7 @@ class EditorState { _insureLastNodeEditable(tr); if (tr.operations.isNotEmpty) { - apply(tr, ruleCount: ruleCount + 1); + apply(tr, ruleCount: ruleCount + 1, withUpdateCursor: false); } } diff --git a/frontend/app_flowy/packages/appflowy_editor/test/infra/test_editor.dart b/frontend/app_flowy/packages/appflowy_editor/test/infra/test_editor.dart index d371895487..e5d171d417 100644 --- a/frontend/app_flowy/packages/appflowy_editor/test/infra/test_editor.dart +++ b/frontend/app_flowy/packages/appflowy_editor/test/infra/test_editor.dart @@ -157,7 +157,9 @@ class EditorWidgetTester { document: Document( root: _createEmptyEditorRoot(), ), - )..disableSealTimer = true; + ) + ..disableSealTimer = true + ..disbaleRules = true; } }