diff --git a/lib/model/emoji.dart b/lib/model/emoji.dart index b0ec5f7324..1e6e75a995 100644 --- a/lib/model/emoji.dart +++ b/lib/model/emoji.dart @@ -1,6 +1,6 @@ import 'package:collection/collection.dart'; import 'package:flutter/foundation.dart'; - +import 'package:diacritic/diacritic.dart'; import '../api/model/events.dart'; import '../api/model/initial_snapshot.dart'; import '../api/model/model.dart'; @@ -462,7 +462,7 @@ class EmojiAutocompleteQuery extends ComposeAutocompleteQuery { static const _separator = '_'; static String _adjustQuery(String raw) { - return raw.toLowerCase().replaceAll(' ', '_'); // TODO(#1067) remove diacritics too + return removeDiacritics(raw.toLowerCase()).replaceAll(' ', '_'); } @override @@ -508,17 +508,16 @@ class EmojiAutocompleteQuery extends ComposeAutocompleteQuery { // for the finer distinctions. // See also commentary in [_rankResult]. - // TODO(#1067) this assumes emojiName is already lower-case (and no diacritics) - if (emojiName == _adjusted) return EmojiMatchQuality.exact; - if (emojiName.startsWith(_adjusted)) return EmojiMatchQuality.prefix; - if (emojiName.contains(_sepAdjusted)) return EmojiMatchQuality.wordAligned; + final normalizedEmojiName = removeDiacritics(emojiName.toLowerCase()); + + if (normalizedEmojiName == _adjusted) return EmojiMatchQuality.exact; + if (normalizedEmojiName.startsWith(_adjusted)) return EmojiMatchQuality.prefix; + if (normalizedEmojiName.contains(_sepAdjusted)) return EmojiMatchQuality.wordAligned; if (!_adjusted.contains(_separator)) { // If the query is a single token (doesn't contain a separator), // allow a match anywhere in the string, too. - if (emojiName.contains(_adjusted)) return EmojiMatchQuality.other; - } else { - // Otherwise, require at least a word-aligned match. - } + if (normalizedEmojiName.contains(_adjusted)) return EmojiMatchQuality.other; + } return null; } diff --git a/pubspec.yaml b/pubspec.yaml index c95e6fb353..8659fb51b5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -41,6 +41,7 @@ dependencies: crypto: ^3.0.3 device_info_plus: ^11.2.0 drift: ^2.23.0 + diacritic: ^0.1.6 file_picker: ^9.0.2 firebase_core: ^3.3.0 firebase_messaging: ^15.0.1