people: Improve mentioning users with diacritics in their name.

This makes it possible to mention a user with a name like Gaël that
contains diacritics by typing e.g. "Gael", significantly reducing the
need to use a special keyboard to mention other users.

Fixes #11183.
This commit is contained in:
ss62171
2019-01-23 02:33:50 +05:30
committed by Tim Abbott
parent 805ec5fbdb
commit b7a0a45f01
3 changed files with 22 additions and 4 deletions

View File

@@ -739,7 +739,7 @@ exports.incr_recipient_count = function (user_id) {
// Diacritic removal from:
// https://stackoverflow.com/questions/18236208/perform-a-find-match-with-javascript-ignoring-special-language-characters-acce
function remove_diacritics(s) {
exports.remove_diacritics = function (s) {
if (/^[a-z]+$/.test(s)) {
return s;
}
@@ -751,7 +751,7 @@ function remove_diacritics(s) {
.replace(/[úùüû]/g, "u")
.replace(/[ç]/g, "c")
.replace(/[ñ]/g, "n");
}
};
exports.person_matches_query = function (user, query) {
var email = user.email.toLowerCase();
@@ -770,7 +770,7 @@ exports.person_matches_query = function (user, query) {
return _.any(names, function (name) {
if (is_ascii) {
// Only ignore diacritics if the query is plain ascii
name = remove_diacritics(name);
name = exports.remove_diacritics(name);
}
if (name.indexOf(termlet) === 0) {
return true;