Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
typeahead: Extract matching logic into a new function.
apoorvapendsee0c786c7a0d7
diff --git a/web/shared/src/typeahead.ts b/web/shared/src/typeahead.tsindex fc1bc132359..a299463b519 100644--- a/web/shared/src/typeahead.ts+++ b/web/shared/src/typeahead.ts@@ -90,10 +90,6 @@ export function last_prefix_match(prefix: string, words: string[]): number | nulreturn null;}-// This function attempts to match a query in order with a source text.-// * query is the user-entered search query-// * source_str is the string we're matching in, e.g. a user's name-// * split_char is the separator for this syntax (e.g. ' ').export function query_matches_string_in_order(query: string,source_str: string,@@ -105,6 +101,18 @@ export function query_matches_string_in_order(query = query.toLowerCase();query = remove_diacritics(query);+ return query_matches_string_in_order_assume_canonicalized(query, source_str, split_char);+}++// This function attempts to match a query in order with a source text.+// * query is the user-entered search query+// * source_str is the string we're matching in, e.g. a user's name+// * split_char is the separator for this syntax (e.g. ' ').+export function query_matches_string_in_order_assume_canonicalized(+ query: string,+ source_str: string,+ split_char: string,+): boolean {if (!query.includes(split_char)) {// If query is a single token (doesn't contain a separator),// the match can be anywhere in the string.