search_suggestion: Canonicalize search text terms before suggesting.

Fixes bug reported here
https://chat.zulip.org/#narrow/channel/9-issues/topic/search.20typeahead.20duplicates.20.22sent.20by.20me.22/near/2183976
This commit is contained in:
Evy Kassirer
2025-06-01 13:46:12 -07:00
committed by Tim Abbott
parent b63b4a26c8
commit b31d3ce5b9
2 changed files with 10 additions and 2 deletions

View File

@@ -1050,7 +1050,7 @@ export function get_search_result(
add_current_filter = false,
): Suggestion[] {
let suggestion_line: SuggestionLine;
text_search_terms = text_search_terms.map((term) => Filter.canonicalize_term(term));
// search_terms correspond to the terms for the query in the input.
// This includes the entire query entered in the searchbox.
// terms correspond to the terms for the entire query entered in the searchbox.

View File

@@ -184,7 +184,15 @@ test("dm_suggestions", ({override, mock_template}) => {
query = "is:private";
suggestions = get_suggestions(query);
expected = ["is:dm"];
// Same search suggestions as for "is:dm"
expected = [
"is:dm",
"dm:alice@zulip.com",
"dm:bob@zulip.com",
"dm:jeff@zulip.com",
"dm:myself@zulip.com",
"dm:ted@zulip.com",
];
assert.deepEqual(suggestions.strings, expected);
query = "dm:t";