Require three characters to match :100, :1234 to avoid catching times #1148

This commit is contained in:
Ben Gotow 2018-11-03 19:34:42 -07:00
parent fc32702fb8
commit efcbf996d6

View file

@ -252,10 +252,15 @@ function onKeyUp(event, change, editor) {
} }
let suggestions = []; let suggestions = [];
let picked = emoji.data.get('picked'); let picked = emoji.data.get('picked');
if (typed.length >= 3) { if (typed.length >= 3) {
suggestions = getEmojiSuggestions(typed.replace(':', '')); const typedEmoji = typed.replace(':', '');
const pickedIdx = suggestions.indexOf(picked); const isNumeric = `${typedEmoji / 1}` === typedEmoji;
picked = suggestions[pickedIdx === -1 ? 0 : pickedIdx]; if (!isNumeric || typedEmoji.length >= 3) {
suggestions = getEmojiSuggestions(typedEmoji);
const pickedIdx = suggestions.indexOf(picked);
picked = suggestions[pickedIdx === -1 ? 0 : pickedIdx];
}
} }
updateEmojiMark(change, emoji, { typed, suggestions, picked }); updateEmojiMark(change, emoji, { typed, suggestions, picked });
} }