fix(#45): emoji autocomplete substring matching + check aliases

Match the typed text anywhere in the shortcode name (not just the prefix),
ranked exact > prefix > substring, so `:check` surfaces the checkmarks ( is
`white_check_mark`). Add check/checkmark/tick aliases for  in a separate,
regen-safe map the chat + channel composers consume.

Closes #45

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
pull/47/head
Strycher 1 month ago
parent e84f171a91
commit 1aaffb380d

@ -1916,3 +1916,17 @@ const Map<String, String> emojiShortcodes = {
'zombie_woman': '🧟‍♀️',
'zzz': '💤',
};
// Hand-authored aliases (not gemoji), kept separate so regenerating the map
// above never clobbers them. is `white_check_mark`, hence `check`.
const Map<String, String> _emojiAliases = {
'check': '',
'checkmark': '',
'tick': '',
};
/// gemoji shortcodes plus [_emojiAliases] what composers use.
final Map<String, String> emojiShortcodesWithAliases = {
...emojiShortcodes,
..._emojiAliases,
};

@ -1250,7 +1250,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
controller: _textController,
focusNode: _textFieldFocusNode,
candidates: _buildMentionCandidates(connector),
emojiShortcodes: emojiShortcodes,
emojiShortcodes: emojiShortcodesWithAliases,
hintText: context.l10n.chat_typeMessage,
onSubmitted: (_) => _sendMessage(),
encoder:

@ -627,7 +627,7 @@ class _ChatScreenState extends State<ChatScreen> {
controller: _textController,
focusNode: _textFieldFocusNode,
candidates: const [],
emojiShortcodes: emojiShortcodes,
emojiShortcodes: emojiShortcodesWithAliases,
hintText: context.l10n.chat_typeMessage,
onSubmitted: (_) => _sendMessage(connector),
encoder:

@ -277,14 +277,18 @@ class _MentionAutocompleteFieldState extends State<MentionAutocompleteField> {
return;
}
}
final names = shortcodes.keys.where((k) => k.startsWith(query)).toList();
final names = shortcodes.keys.where((k) => k.contains(query)).toList();
if (names.isEmpty) {
_close();
return;
}
names.sort((a, b) {
// Rank exact, then prefix, then mid-name matches; shorter names first.
if (a == query && b != query) return -1;
if (b == query && a != query) return 1;
final aPrefix = a.startsWith(query);
final bPrefix = b.startsWith(query);
if (aPrefix != bPrefix) return aPrefix ? -1 : 1;
final byLen = a.length.compareTo(b.length);
if (byLen != 0) return byLen;
return a.compareTo(b);

Loading…
Cancel
Save

Powered by TurnKey Linux.