mirror of https://github.com/zulip/zulip.git
Handle negated topics in search suggestions.
Typing "stream:foo -topic:b" leads to "stream:foo -topic:bar" properly as a suggestion now. (imported from commit bb0acf52744f7b13977a3db5d3c130d1402b09b7)
This commit is contained in:
parent
30f9fed766
commit
e5e0ba9e7c
|
@ -195,6 +195,7 @@ function get_topic_suggestions(query_operators) {
|
|||
var last_term = query_operators.slice(-1)[0];
|
||||
var operator = Filter.canonicalize_operator(last_term.operator);
|
||||
var operand = last_term.operand;
|
||||
var negated = (operator === 'topic') && (last_term.negated);
|
||||
var stream;
|
||||
var guess;
|
||||
var filter;
|
||||
|
@ -277,7 +278,7 @@ function get_topic_suggestions(query_operators) {
|
|||
topics.sort();
|
||||
|
||||
return _.map(topics, function (topic) {
|
||||
var topic_term = {operator: 'topic', operand: topic};
|
||||
var topic_term = {operator: 'topic', operand: topic, negated: negated};
|
||||
var operators = query_operators.concat([topic_term]);
|
||||
var search_string = Filter.unparse(operators);
|
||||
var description = Filter.describe(operators);
|
||||
|
|
|
@ -16,7 +16,9 @@ add_dependencies({
|
|||
|
||||
var search = require('js/search_suggestion.js');
|
||||
|
||||
set_global('feature_flags', {});
|
||||
set_global('feature_flags', {
|
||||
negated_search: true
|
||||
});
|
||||
set_global('page_params', {
|
||||
email: 'bob@zulip.com'
|
||||
});
|
||||
|
@ -262,6 +264,22 @@ set_global('narrow', {});
|
|||
'stream:devel'
|
||||
];
|
||||
assert.deepEqual(suggestions.strings, expected);
|
||||
|
||||
suggestions = search.get_suggestions('stream:devel -topic:');
|
||||
expected = [
|
||||
'stream:devel -topic:',
|
||||
'stream:devel -topic:REXX',
|
||||
'stream:devel'
|
||||
];
|
||||
assert.deepEqual(suggestions.strings, expected);
|
||||
|
||||
suggestions = search.get_suggestions('-topic:te');
|
||||
expected = [
|
||||
'-topic:te',
|
||||
'stream:office -topic:team',
|
||||
'stream:office -topic:test'
|
||||
];
|
||||
assert.deepEqual(suggestions.strings, expected);
|
||||
}());
|
||||
|
||||
(function test_whitespace_glitch() {
|
||||
|
|
Loading…
Reference in New Issue