From 64ea29f46d8639c5658a366e0bbe444bb9b9d137 Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Tue, 22 Aug 2017 11:04:38 +0300 Subject: [PATCH] Only match emoji autocomplete after two characters --- client/js/lounge.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/js/lounge.js b/client/js/lounge.js index 23e8dd5e..ec937737 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -48,10 +48,12 @@ $(function() { const emojiSearchTerms = Object.keys(emojiMap); const emojiStrategy = { id: "emoji", - match: /\B:([-+\w]*):?$/, + match: /\B:([-+\w:?]{2,}):?$/, search(term, callback) { const results = fuzzy.filter( - term, + // Trim colon from the matched term, + // as we are unable to get a clean string from match regex + term.replace(/:$/, ""), emojiSearchTerms, { pre: "",