Skip to content

Commit 04e32a8

Browse files
fix: emoji diacritic
1 parent 2f5942f commit 04e32a8

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/model/emoji.dart

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:collection/collection.dart';
22
import 'package:flutter/foundation.dart';
3-
3+
import 'package:diacritic/diacritic.dart';
44
import '../api/model/events.dart';
55
import '../api/model/initial_snapshot.dart';
66
import '../api/model/model.dart';
@@ -459,7 +459,7 @@ class EmojiAutocompleteQuery extends ComposeAutocompleteQuery {
459459
static const _separator = '_';
460460

461461
static String _adjustQuery(String raw) {
462-
return raw.toLowerCase().replaceAll(' ', '_'); // TODO(#1067) remove diacritics too
462+
return removeDiacritics(raw.toLowerCase()).replaceAll(' ', '_');
463463
}
464464

465465
@override
@@ -505,17 +505,16 @@ class EmojiAutocompleteQuery extends ComposeAutocompleteQuery {
505505
// for the finer distinctions.
506506
// See also commentary in [_rankResult].
507507

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;
512513
if (!_adjusted.contains(_separator)) {
513514
// If the query is a single token (doesn't contain a separator),
514515
// 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+
}
519518
return null;
520519
}
521520

0 commit comments

Comments
 (0)