File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -348,12 +348,19 @@ class MentionAutocompleteView extends ChangeNotifier {
348
348
_sortUsers ();
349
349
}
350
350
351
- final iterator = _sortedUsers! .iterator;
351
+ final sortedUsers = _sortedUsers! ;
352
+ final iterator = sortedUsers.iterator;
352
353
bool isDone = false ;
353
354
while (! isDone) {
354
355
// CPU perf: End this task; enqueue a new one for resuming this work
355
356
await Future (() {});
356
357
358
+ if (_sortedUsers != sortedUsers) {
359
+ // The list of users this loop has been working from has become stale.
360
+ // Abort so _startSearch can retry with the new list.
361
+ throw ConcurrentModificationError ();
362
+ }
363
+
357
364
if (query != _query || ! hasListeners) { // false if [dispose] has been called.
358
365
return null ;
359
366
}
You can’t perform that action at this time.
0 commit comments