typeahead: Fix '@topic' not present when stream wildcard suggested.

Earlier, we suggested only the first matching wildcard mention,
irrespective of how many equivalent wildcard mentions match.

That logic leads to the exclusion of '@topic' suggestion whenever
a stream wildcard is suggested, which is not correct as
stream wildcards and topic wildcard are not equivalent.

This commit updates the logic to make the behavior of suggesting
only the first match valid for stream wildcard mentions only.
This commit is contained in:
Prakhar Pratyush
2023-11-14 11:57:19 +05:30
committed by Tim Abbott
parent fb9e258a65
commit c76b3acce7
2 changed files with 15 additions and 8 deletions

View File

@@ -1753,8 +1753,8 @@ test("typeahead_results", () => {
// Verify we're not matching on a terms that only appear in the description.
assert_mentions_matches("characters of", []);
// Verify we suggest only the first matching wildcard mention,
// irrespective of how many equivalent wildcard mentions match.
// Verify we suggest only the first matching stream wildcard mention,
// irrespective of how many equivalent stream wildcard mentions match.
const mention_everyone = ct.broadcast_mentions()[1];
// Here, we suggest only "everyone" instead of both the matching
// "everyone" and "stream" wildcard mentions.
@@ -1771,6 +1771,12 @@ test("typeahead_results", () => {
call_center,
]);
// Verify we suggest both 'the first matching stream wildcard' and
// 'topic wildcard' mentions. Not only one matching wildcard mention.
const mention_topic = ct.broadcast_mentions()[3];
// Here, we suggest both "everyone" and "topic".
assert_mentions_matches("o", [othello, mention_everyone, mention_topic, cordelia]);
// Autocomplete by slash commands.
assert_slash_matches("me", [me_slash]);
assert_slash_matches("dark", [dark_slash]);