浏览代码

fix: use UnmodifiableListView for OpIterator

Vincent Chan 2 年之前
父节点
当前提交
de507001f4
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      frontend/app_flowy/packages/flowy_editor/lib/document/text_delta.dart

+ 3 - 2
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;