mirror of
https://github.com/zulip/zulip.git
synced 2026-07-12 21:04:41 +08:00
Suggest "widening" searches in search autocomplete.
This will allow you to always get Home from the search box, as well as easily backing out narrows. (imported from commit 68bcfc83ce0428645f4e734ae46f9589cb562a86)
This commit is contained in:
parent
4b69094ffd
commit
ffa178cf7a
@ -340,6 +340,32 @@ function get_topic_suggestions(query, query_operators) {
|
||||
});
|
||||
}
|
||||
|
||||
function get_operator_subset_suggestions(query, operators) {
|
||||
// If you have stream:foo topic:x search:needle, then
|
||||
// suggest "stream:foo" and "stream:foo topic:x" so that
|
||||
// power users can use search as a quick mouse-free way
|
||||
// to de-narrow. This won't cause too much clutter, as
|
||||
// you generally only have 1 to 3 operators, and this gives
|
||||
// N-1 additional suggestions.
|
||||
if (operators.length < 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var i;
|
||||
var suggestions = [];
|
||||
|
||||
for (i = 0; i < operators.length; ++i) {
|
||||
var subset = operators.slice(0, i);
|
||||
var search_string = narrow.unparse(subset);
|
||||
var description = describe(subset);
|
||||
var suggestion = {description: description, search_string: search_string};
|
||||
suggestions.push(suggestion);
|
||||
}
|
||||
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
|
||||
function get_special_filter_suggestions(query, operators) {
|
||||
if (operators.length >= 2) {
|
||||
return [];
|
||||
@ -403,6 +429,9 @@ exports.initialize = function () {
|
||||
suggestions = get_special_filter_suggestions(query, operators);
|
||||
result = result.concat(suggestions);
|
||||
|
||||
suggestions = get_operator_subset_suggestions(query, operators);
|
||||
result = result.concat(suggestions);
|
||||
|
||||
suggestions = get_stream_suggestions(query);
|
||||
result = result.concat(suggestions);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user