Skip to content

Commit ce5beaa

Browse files
committed
autocomplete [nfc]: Shorten local names in intent-finding
In particular the regex is effectively private to this logic, so we can make it a private variable and then simplify its name.
1 parent 1c01908 commit ce5beaa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/model/autocomplete.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ extension ComposeContentAutocomplete on ComposeContentController {
3232
}
3333

3434
final textUntilCursor = text.substring(0, selection.end);
35-
for (int position = selection.end - 1; position >= earliest; position--) {
36-
if (textUntilCursor[position] != '@') {
35+
for (int pos = selection.end - 1; pos >= earliest; pos--) {
36+
if (textUntilCursor[pos] != '@') {
3737
continue;
3838
}
39-
final match = mentionAutocompleteMarkerRegex.matchAsPrefix(textUntilCursor, position);
39+
final match = _mentionIntentRegex.matchAsPrefix(textUntilCursor, pos);
4040
if (match == null) {
4141
continue;
4242
}
43-
if (selection.start < position) {
43+
if (selection.start < pos) {
4444
// See comment about [TextSelection.isCollapsed] above.
4545
return null;
4646
}
4747
return AutocompleteIntent(
48-
syntaxStart: position,
48+
syntaxStart: pos,
4949
query: MentionAutocompleteQuery(match[2]!, silent: match[1]! == '_'),
5050
textEditingValue: value);
5151
}
@@ -62,7 +62,7 @@ extension ComposeTopicAutocomplete on ComposeTopicController {
6262
}
6363
}
6464

65-
final RegExp mentionAutocompleteMarkerRegex = (() {
65+
final RegExp _mentionIntentRegex = (() {
6666
// What's likely to come before an @-mention: the start of the string,
6767
// whitespace, or punctuation. Letters are unlikely; in that case an email
6868
// might be intended. (By punctuation, we mean *some* punctuation, like "(".

0 commit comments

Comments
 (0)