Skip to content

Commit

Permalink
Fix emoticon autocompletion
Browse files Browse the repository at this point in the history
Search for `:<search-query>` first and fill up missing results with
`<search-query>` (stripping the `:`). This improves results for emoji
autocompletion when typing emoticons (like `:)`, `:D`, `:P` and so on).

Fixes: #3825

Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- committed Mar 23, 2023
1 parent fb40dc2 commit a86526e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/functions/emoji/emoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ import { EmojiIndex, frequently } from 'emoji-mart-vue-fast'
export const emojiSearch = function(query, maxResults = 10) {
const index = new EmojiIndex(data)
if (query) {
return index.search(query, maxResults) || []
let results = index.search(`:${query}`, maxResults).map(e => e.native)
if (results.length < maxResults) {
results = results.concat(index.search(query, maxResults - results.length).map(e => e.native))
}
return results
}

return frequently.get(maxResults).map((id) => index.emoji(id)) || []
Expand Down

0 comments on commit a86526e

Please sign in to comment.