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).

Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- committed Mar 23, 2023
1 parent fb40dc2 commit f3b1caf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/functions/emoji/emoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ 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) || []
var 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 f3b1caf

Please sign in to comment.