Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4391 from matrix-org/t3chguy/sort_emoji_by_shortc…
Browse files Browse the repository at this point in the history
…odes

Sort emoji by shortcodes for autocomplete primarily for :-1 and :+1
  • Loading branch information
t3chguy authored Apr 14, 2020
2 parents 17a893a + e114eff commit 3aa338f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/autocomplete/EmojiProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export default class EmojiProvider extends AutocompleteProvider {

// then sort by score (Infinity if matchedString not in shortname)
sorters.push((c) => score(matchedString, c.shortname));
// then sort by max score of all shortcodes, trim off the `:`
sorters.push((c) => Math.min(...c.emoji.shortcodes.map(s => score(matchedString.substring(1), s))));
// If the matchedString is not empty, sort by length of shortname. Example:
// matchedString = ":bookmark"
// completions = [":bookmark:", ":bookmark_tabs:", ...]
Expand Down

0 comments on commit 3aa338f

Please sign in to comment.