|
1 | 1 | import 'package:collection/collection.dart';
|
2 | 2 | import 'package:flutter/foundation.dart';
|
3 |
| - |
| 3 | +import 'package:diacritic/diacritic.dart'; |
4 | 4 | import '../api/model/events.dart';
|
5 | 5 | import '../api/model/initial_snapshot.dart';
|
6 | 6 | import '../api/model/model.dart';
|
@@ -459,7 +459,7 @@ class EmojiAutocompleteQuery extends ComposeAutocompleteQuery {
|
459 | 459 | static const _separator = '_';
|
460 | 460 |
|
461 | 461 | static String _adjustQuery(String raw) {
|
462 |
| - return raw.toLowerCase().replaceAll(' ', '_'); // TODO(#1067) remove diacritics too |
| 462 | + return removeDiacritics(raw.toLowerCase()).replaceAll(' ', '_'); |
463 | 463 | }
|
464 | 464 |
|
465 | 465 | @override
|
@@ -505,17 +505,16 @@ class EmojiAutocompleteQuery extends ComposeAutocompleteQuery {
|
505 | 505 | // for the finer distinctions.
|
506 | 506 | // See also commentary in [_rankResult].
|
507 | 507 |
|
508 |
| - // TODO(#1067) this assumes emojiName is already lower-case (and no diacritics) |
509 |
| - if (emojiName == _adjusted) return EmojiMatchQuality.exact; |
510 |
| - if (emojiName.startsWith(_adjusted)) return EmojiMatchQuality.prefix; |
511 |
| - if (emojiName.contains(_sepAdjusted)) return EmojiMatchQuality.wordAligned; |
| 508 | + final normalizedEmojiName = removeDiacritics(emojiName.toLowerCase()); |
| 509 | + |
| 510 | + if (normalizedEmojiName == _adjusted) return EmojiMatchQuality.exact; |
| 511 | + if (normalizedEmojiName.startsWith(_adjusted)) return EmojiMatchQuality.prefix; |
| 512 | + if (normalizedEmojiName.contains(_sepAdjusted)) return EmojiMatchQuality.wordAligned; |
512 | 513 | if (!_adjusted.contains(_separator)) {
|
513 | 514 | // If the query is a single token (doesn't contain a separator),
|
514 | 515 | // allow a match anywhere in the string, too.
|
515 |
| - if (emojiName.contains(_adjusted)) return EmojiMatchQuality.other; |
516 |
| - } else { |
517 |
| - // Otherwise, require at least a word-aligned match. |
518 |
| - } |
| 516 | + if (normalizedEmojiName.contains(_adjusted)) return EmojiMatchQuality.other; |
| 517 | + } |
519 | 518 | return null;
|
520 | 519 | }
|
521 | 520 |
|
|
0 commit comments