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

Sort emoji by shortcodes for autocomplete primarily for :-1 and :+1 #4391

Merged
merged 2 commits into from
Apr 14, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/autocomplete/EmojiProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ 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) => {
return Math.min.apply(null, c.emoji.shortcodes.map(s => score(matchedString.substring(1), s)));
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
});
// If the matchedString is not empty, sort by length of shortname. Example:
// matchedString = ":bookmark"
// completions = [":bookmark:", ":bookmark_tabs:", ...]
Expand Down