Skip to content

Commit e94eb20

Browse files
committed
chore: disable rules for test cases
1 parent 8bbae46 commit e94eb20

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

frontend/app_flowy/packages/appflowy_editor/lib/src/editor_state.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class EditorState {
7373

7474
// TODO: only for testing.
7575
bool disableSealTimer = false;
76+
bool disbaleRules = false;
7677

7778
bool editable = true;
7879

@@ -124,6 +125,7 @@ class EditorState {
124125
Transaction transaction, {
125126
ApplyOptions options = const ApplyOptions(recordUndo: true),
126127
ruleCount = 0,
128+
withUpdateCursor = true,
127129
}) {
128130
if (!editable) {
129131
return;
@@ -137,7 +139,9 @@ class EditorState {
137139

138140
WidgetsBinding.instance.addPostFrameCallback((_) {
139141
_applyRules(ruleCount);
140-
updateCursorSelection(transaction.afterSelection);
142+
if (withUpdateCursor) {
143+
updateCursorSelection(transaction.afterSelection);
144+
}
141145
});
142146

143147
if (options.recordUndo) {
@@ -187,7 +191,7 @@ class EditorState {
187191

188192
void _applyRules(int ruleCount) {
189193
// Set a maximum count to prevent a dead loop.
190-
if (ruleCount >= 5) {
194+
if (ruleCount >= 5 || disbaleRules) {
191195
return;
192196
}
193197

@@ -197,7 +201,7 @@ class EditorState {
197201
_insureLastNodeEditable(tr);
198202

199203
if (tr.operations.isNotEmpty) {
200-
apply(tr, ruleCount: ruleCount + 1);
204+
apply(tr, ruleCount: ruleCount + 1, withUpdateCursor: false);
201205
}
202206
}
203207

frontend/app_flowy/packages/appflowy_editor/test/infra/test_editor.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ class EditorWidgetTester {
157157
document: Document(
158158
root: _createEmptyEditorRoot(),
159159
),
160-
)..disableSealTimer = true;
160+
)
161+
..disableSealTimer = true
162+
..disbaleRules = true;
161163
}
162164
}
163165

0 commit comments

Comments
 (0)