Skip to content

Commit

Permalink
boxes: Generate complete emoji list for autocomplete from aliases too.
Browse files Browse the repository at this point in the history
This commit expands the state space for emoji autocomplete by including
emoji names from aliases too. According to our new structure of storing
emoji's, we have a single emoji_name (aka canonical_name) for each code
and all other emoji_names carrying the same emoji_code are stored as
aliases of the canonical emoji.

Tests amended.
  • Loading branch information
zee-bit committed Jul 19, 2021
1 parent 299cd6c commit d7339ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tests/ui_tools/test_boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,9 @@ def test_generic_autocomplete_streams(
(":jo", 1, ":joy_cat:"),
(":jok", 0, ":joker:"),
(":", 0, ":happy:"),
(":", 1, ":joker:"),
(":", -2, ":smiley:"),
(":", -1, ":smirk:"),
(":", 1, ":grinning:"),
(":", -2, ":smirk:"),
(":", -1, ":smug:"),
(":nomatch", 0, None),
(":nomatch", -1, None),
# Complex autocomplete prefixes.
Expand Down
5 changes: 4 additions & 1 deletion zulipterminal/ui_tools/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,10 @@ def autocomplete_streams(
def autocomplete_emojis(
self, text: str, prefix_string: str
) -> Tuple[List[str], List[str]]:
emoji_list = list(self.model.active_emoji_data.keys())
emoji_list = []
for emoji_name, emoji_data in self.model.active_emoji_data.items():
emoji_list.append(emoji_name)
emoji_list.extend(emoji_data["aliases"])
emojis = [emoji for emoji in emoji_list if match_emoji(emoji, text[1:])]
emoji_typeahead = format_string(emojis, ":{}:")

Expand Down

0 comments on commit d7339ae

Please sign in to comment.