Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: use UnmodifiableListView for OpIterator

Vincent Chande507001f4c5
diff --git a/frontend/app_flowy/packages/flowy_editor/lib/document/text_delta.dart b/frontend/app_flowy/packages/flowy_editor/lib/document/text_delta.dart
index c799fa65c2..30d3b81b9f 100644
--- a/frontend/app_flowy/packages/flowy_editor/lib/document/text_delta.dart
+++ b/frontend/app_flowy/packages/flowy_editor/lib/document/text_delta.dart
@@ -1,3 +1,4 @@
+import 'dart:collection';
import 'dart:math';
import 'package:flutter/foundation.dart';
@@ -140,11 +141,11 @@ class TextDelete extends TextOperation {
}
class _OpIterator {
- final List<TextOperation> _operations;
+ final UnmodifiableListView<TextOperation> _operations;
int _index = 0;
int _offset = 0;
- _OpIterator(List<TextOperation> operations) : _operations = operations;
+ _OpIterator(List<TextOperation> operations) : _operations = UnmodifiableListView(operations);
bool get hasNext {
return peekLength() < _maxInt;