Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
search_suggestion: Don't show operator suggestion if its incompatible.
Pratik Chanda5c16549b8a50
diff --git a/web/src/search_suggestion.ts b/web/src/search_suggestion.tsindex f2e53aa195b..e3413206311 100644--- a/web/src/search_suggestion.ts+++ b/web/src/search_suggestion.ts@@ -799,7 +799,7 @@ function get_sent_by_me_suggestions(last: NarrowTerm, terms: NarrowTerm[]): Suggreturn [];}-function get_operator_suggestions(last: NarrowTerm): Suggestion[] {+function get_operator_suggestions(last: NarrowTerm, terms: NarrowTerm[]): Suggestion[] {if (!(last.operator === "search" || last.operator === "")) {return [];}@@ -831,7 +831,14 @@ function get_operator_suggestions(last: NarrowTerm): Suggestion[] {];}- choices = choices.filter((choice) => common.phrase_match(last_operand, choice));+ // We remove suggestion choice if its incompatible_pattern matches+ // that of current search terms.+ choices = choices.filter(+ (choice) =>+ common.phrase_match(last_operand, choice) &&+ (!incompatible_patterns[choice] ||+ !match_criteria(terms, incompatible_patterns[choice])),+ );return choices.map((choice) => {// Map results for "dm:" operator for users