@@ -32,23 +32,33 @@ extension ComposeContentAutocomplete on ComposeContentController {
32
32
}
33
33
34
34
final textUntilCursor = text.substring (0 , selection.end);
35
- for (int pos = selection.end - 1 ; pos >= earliest; pos-- ) {
35
+ int pos;
36
+ for (pos = selection.end - 1 ; pos > selection.start; pos-- ) {
36
37
final charAtPos = textUntilCursor[pos];
37
38
if (charAtPos == '@' ) {
38
39
final match = _mentionIntentRegex.matchAsPrefix (textUntilCursor, pos);
39
- if (match == null ) {
40
- continue ;
41
- }
42
- if (selection.start < pos) {
43
- // See comment about [TextSelection.isCollapsed] above.
44
- return null ;
45
- }
46
- return AutocompleteIntent (
47
- syntaxStart: pos,
48
- query: MentionAutocompleteQuery (match[2 ]! , silent: match[1 ]! == '_' ),
49
- textEditingValue: value);
40
+ if (match == null ) continue ;
41
+ } else {
42
+ continue ;
50
43
}
44
+ // See comment about [TextSelection.isCollapsed] above.
45
+ return null ;
46
+ }
47
+
48
+ for (; pos >= earliest; pos-- ) {
49
+ final charAtPos = textUntilCursor[pos];
50
+ final ComposeAutocompleteQuery query;
51
+ if (charAtPos == '@' ) {
52
+ final match = _mentionIntentRegex.matchAsPrefix (textUntilCursor, pos);
53
+ if (match == null ) continue ;
54
+ query = MentionAutocompleteQuery (match[2 ]! , silent: match[1 ]! == '_' );
55
+ } else {
56
+ continue ;
57
+ }
58
+ return AutocompleteIntent (syntaxStart: pos, textEditingValue: value,
59
+ query: query);
51
60
}
61
+
52
62
return null ;
53
63
}
54
64
}
0 commit comments