File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change
1
+ import 'dart:math' ;
2
+
1
3
import 'package:flutter/foundation.dart' ;
2
4
import 'package:flutter/services.dart' ;
3
5
@@ -18,12 +20,13 @@ extension ComposeContentAutocomplete on ComposeContentController {
18
20
// see below.
19
21
return null ;
20
22
}
23
+
24
+ // To avoid spending a lot of time searching for autocomplete intents
25
+ // in long messages, we bound how far back we look for the intent's start.
26
+ final earliest = max (0 , selection.end - 30 );
27
+
21
28
final textUntilCursor = text.substring (0 , selection.end);
22
- for (
23
- int position = selection.end - 1 ;
24
- position >= 0 && (selection.end - position <= 30 );
25
- position--
26
- ) {
29
+ for (int position = selection.end - 1 ; position >= earliest; position-- ) {
27
30
if (textUntilCursor[position] != '@' ) {
28
31
continue ;
29
32
}
You can’t perform that action at this time.
0 commit comments