hugovk / em-keyboard

The CLI emoji keyboard
ISC License
310 stars 31 forks source link

Emoji with spaces in their names do not work #61

Closed wuggen closed 3 years ago

wuggen commented 3 years ago

Emoji whose canonical names contain spaces do not appear when queried directly, or when searched for with their exact names:

$ em -s disguised
πŸ₯Έ  disguised face

$ em -s hugging
πŸ€—  hugging_face
πŸ«‚  people hugging

$ em -s transgender
πŸ³οΈβ€πŸŒˆ  rainbow_flag
⚧️  transgender symbol
πŸ³οΈβ€βš§οΈ  transgender flag

$ em 'disguised face'
[1]

$ em 'people hugging'
[1]

$ em 'transgender flag'
[1]

$ em -s 'disguised face'
# no output

$ em -s 'people hugging'
# no output

$ em -s 'transgender flag'
# no output

This seems to be because em currently replaces any spaces, periods, or hyphens in the query text with underscores: https://github.com/hugovk/em-keyboard/blob/c1c9afc1f761fc7084d080b690b151a7dc78478b/em/__init__.py#L73-L76

yet has emoji in its dictionary whose canonical names contain spaces: https://github.com/hugovk/em-keyboard/blob/c1c9afc1f761fc7084d080b690b151a7dc78478b/em/emoji-en-US.json#L11885-L11891

making them impossible to reference directly.

I believe the most straightforward options here are:

  1. Remove all spaces in all emoji names in the dictionary, replacing them with underscores, or
  2. Leave spaces in the query text unmodified.

Of the two, I believe the first option is preferable, as the second would be a departure from the existing behavior of the interface.

hugovk commented 3 years ago

I agree the first option sounds good, would you like to test out https://github.com/hugovk/em-keyboard/pull/62?

wuggen commented 3 years ago

Tested with the examples above, seems good to me!

hugovk commented 3 years ago

Thanks for testing, and released in 2.3.1!