search_suggestion: Show operator autocomplete suggestion at top.

Earlier, operator autocomplete suggestion was showed at bottom after
operator with operand value suggestions.

This commit brings operator autocomplete suggestion to higher priority
in the suggestion list.
This commit is contained in:
Pratik Chanda
2025-07-29 00:38:52 +05:30
committed by Tim Abbott
parent b0eefb8a31
commit 9dbd13d5a6
2 changed files with 9 additions and 9 deletions

View File

@@ -1045,6 +1045,7 @@ export function get_search_result(
// searching user probably is looking to make a group DM.
get_group_suggestions,
get_channels_filter_suggestions,
get_operator_suggestions,
get_is_filter_suggestions,
get_sent_by_me_suggestions,
get_channel_suggestions,
@@ -1053,18 +1054,17 @@ export function get_search_result(
get_people("dm-including"),
get_people("from"),
get_topic_suggestions,
get_operator_suggestions,
get_has_filter_suggestions,
];
if (page_params.is_spectator) {
filterers = [
get_operator_suggestions,
get_is_filter_suggestions,
get_channel_suggestions,
get_people("sender"),
get_people("from"),
get_topic_suggestions,
get_operator_suggestions,
get_has_filter_suggestions,
];
}

View File

@@ -576,7 +576,7 @@ test("check_is_suggestions", ({override, mock_template}) => {
// but shows html description used for "channels:public"
query = "st";
suggestions = get_suggestions(query);
expected = ["st", "streams:public", "is:starred", "channel:"];
expected = ["st", "streams:public", "channel:", "is:starred"];
assert.deepEqual(suggestions.strings, expected);
query = "channel:66 has:link is:sta";
@@ -600,22 +600,22 @@ test("sent_by_me_suggestions", ({override, mock_template}) => {
query = "sender";
suggestions = get_suggestions(query);
let expected = ["sender", "sender:myself@zulip.com", "sender:"];
let expected = ["sender", "sender:", "sender:myself@zulip.com"];
assert.deepEqual(suggestions.strings, expected);
query = "-sender";
suggestions = get_suggestions(query);
expected = ["-sender", "-sender:myself@zulip.com", "-sender:"];
expected = ["-sender", "-sender:", "-sender:myself@zulip.com"];
assert.deepEqual(suggestions.strings, expected);
query = "from";
suggestions = get_suggestions(query);
expected = ["from", "sender:myself@zulip.com", "sender:"];
expected = ["from", "sender:", "sender:myself@zulip.com"];
assert.deepEqual(suggestions.strings, expected);
query = "-from";
suggestions = get_suggestions(query);
expected = ["-from", "-sender:myself@zulip.com", "-sender:"];
expected = ["-from", "-sender:", "-sender:myself@zulip.com"];
assert.deepEqual(suggestions.strings, expected);
query = "sender:bob@zulip.com";
@@ -995,7 +995,7 @@ test("operator_suggestions", ({override, mock_template}) => {
query = "-s";
suggestions = get_suggestions(query);
expected = ["-s", "-sender:myself@zulip.com", "-sender:", "-channel:"];
expected = ["-s", "-sender:", "-channel:", "-sender:myself@zulip.com"];
assert.deepEqual(suggestions.strings, expected);
// 66 is a misc channel id.
@@ -1003,8 +1003,8 @@ test("operator_suggestions", ({override, mock_template}) => {
suggestions = get_suggestions(query);
expected = [
"channel:66 is:alerted -f",
"channel:66 is:alerted -sender:myself@zulip.com",
"channel:66 is:alerted -sender:",
"channel:66 is:alerted -sender:myself@zulip.com",
"channel:66 is:alerted",
"channel:66",
];