typeahead: Remove diacritics on full names, not pieces.

This may actually be a slowdown for the worst case
scenario, but it sets us up to be able to easily
short circuit the removal of diacritic characters
for users that have pure ascii names.

For example, czo has lots of names like this:

    - Tim Abbott
    - Steve Howell

Since they're pure ascii, we can do a one-time
check.  A subsequent commit will show how we use
this.
This commit is contained in:
Steve Howell
2019-12-23 15:18:32 +00:00
committed by Tim Abbott
parent 7d7028b7d0
commit d91a0ab9c7

View File

@@ -770,12 +770,15 @@ exports.build_termlet_matcher = function (termlet) {
const is_ascii = /^[a-z]+$/.test(termlet);
return function (names) {
return function (user) {
let full_name = user.full_name;
if (is_ascii) {
// Only ignore diacritics if the query is plain ascii
full_name = exports.remove_diacritics(full_name);
}
const names = full_name.toLowerCase().split(' ');
return _.any(names, function (name) {
if (is_ascii) {
// Only ignore diacritics if the query is plain ascii
name = exports.remove_diacritics(name);
}
if (name.indexOf(termlet) === 0) {
return true;
}
@@ -796,9 +799,8 @@ exports.build_person_matcher = function (query) {
return true;
}
const names = user.full_name.toLowerCase().split(' ');
return _.all(termlet_matchers, function (matcher) {
return matcher(names);
return matcher(user);
});
};
};