Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

search: Bold search operands in the first search result.

evykassirerd293e869bd8e
diff --git a/web/src/search_suggestion.js b/web/src/search_suggestion.js
index a65de3f9e30..a4261250b17 100644
--- a/web/src/search_suggestion.js
+++ b/web/src/search_suggestion.js
@@ -749,7 +749,16 @@ export function get_search_result(query) {
// `has` and `is` operators work only on predefined categories. Default suggestion
// is not displayed in that case. e.g. `messages that contain abc` as
// a suggestion for `has:abc`does not make sense.
- if (last.operator !== "" && last.operator !== "has" && last.operator !== "is") {
+ if (last.operator === "search") {
+ suggestion = {
+ search_string: last.operand,
+ description_html: `search for <strong>${Handlebars.Utils.escapeExpression(
+ last.operand,
+ )}</strong>`,
+ };
+ attacher.prepend_base(suggestion);
+ attacher.push(suggestion);
+ } else if (last.operator !== "" && last.operator !== "has" && last.operator !== "is") {
suggestion = get_default_suggestion(search_operators);
attacher.push(suggestion);
}
diff --git a/web/tests/search_suggestion.test.js b/web/tests/search_suggestion.test.js
index b8c969704be..05daa5cf2e6 100644
--- a/web/tests/search_suggestion.test.js
+++ b/web/tests/search_suggestion.test.js
@@ -79,9 +79,7 @@ function test(label, f) {
});
}
-test("basic_get_suggestions", ({override, mock_template}) => {
- mock_template("search_description.hbs", true, (data, html) => html);
-
+test("basic_get_suggestions", ({override}) => {
const query = "fred";
override(narrow_state, "stream", () => "office");
@@ -717,7 +715,7 @@ test("topic_suggestions", ({override, mock_template}) => {
function describe(q) {
return suggestions.lookup_table.get(q).description_html;
}
- assert.equal(describe("te"), "Search for te");
+ assert.equal(describe("te"), "Search for <strong>te</strong>");
assert.equal(describe("stream:office topic:team"), "Stream office > team");
suggestions = get_suggestions("topic:staplers stream:office");