mirror of
https://github.com/zulip/zulip.git
synced 2025-10-29 11:03:54 +00:00
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:
@@ -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);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user