@@ -172,7 +172,7 @@ function runWithString(input) {
172172 for ( const frequent of frequents ) {
173173 if ( ! query && frequent . counter < freqMin ) continue ;
174174 const keywords = emojiKeywords [ frequent . emoji ] ;
175- const match = emojiMatchResult ( result , query , emojiUnicode , emojiComponents ,
175+ const matchedResult = emojiMatchResult ( result , query , emojiUnicode , emojiComponents ,
176176 frequent . emoji , keywords , frequent . counter . toString ( ) ) ;
177177 }
178178
@@ -181,7 +181,7 @@ function runWithString(input) {
181181 for ( const [ emoji , keywords ] of Object . entries ( emojiKeywords ) ) {
182182 // skip if a frequent usage as already processed
183183 if ( usages [ emoji ] ) continue ;
184- const match = emojiMatchResult ( result , query , emojiUnicode , emojiComponents ,
184+ const matchedResult = emojiMatchResult ( result , query , emojiUnicode , emojiComponents ,
185185 emoji , keywords , null ) ;
186186 }
187187 }
@@ -195,21 +195,22 @@ function runWithString(input) {
195195
196196// check if an emoji matches query and if so add as a result
197197function emojiMatchResult ( result , query , emojiUnicode , emojiComponents , emoji , keywords , badge ) {
198- const keyword = emojiMatch ( query , keywords ) ;
199- if ( keyword )
198+ const { match , keyword} = emojiMatch ( query , keywords ) ;
199+ if ( match )
200200 return emojiResult ( result , emojiUnicode , emojiComponents , emoji , keyword , badge ) ;
201201 return null ;
202202}
203203
204204// check if query matches emoji keywords
205- // return matched query if a match, otherwise null
205+ // return matched keyword if a match, otherwise null
206206function emojiMatch ( query , keywords ) {
207- if ( ! keywords ) return null ;
208- if ( ! query ) return " " ;
207+ if ( ! keywords ) return { "match" : false , "keyword" : null } ;
208+ // empty query everything matches
209+ if ( ! query ) return { "match" : true , "keyword" : null } ;
209210 for ( const keyword of keywords ) {
210- if ( keyword . indexOf ( query ) >= 0 ) return keyword ;
211+ if ( keyword . indexOf ( query ) >= 0 ) return { "match" : true , " keyword" : keyword } ;
211212 }
212- return null ;
213+ return { "match" : false , "keyword" : null } ;
213214}
214215
215216// array of code point integers from string
@@ -291,7 +292,7 @@ function emojiResult(result, emojiUnicode, emojiComponents, emoji, keyword, badg
291292 const match = {
292293 "title" : titleCase ( info . name ) ,
293294 "icon" : emoji ,
294- "subtitle" : keyword ,
295+ "subtitle" : ( keyword ? keyword : "" ) ,
295296 "action" : 'selectedEmoji' ,
296297 "actionArgument" : {
297298 "emoji" : emoji ,
@@ -317,7 +318,7 @@ function emojiResult(result, emojiUnicode, emojiComponents, emoji, keyword, badg
317318 emojiCodes . push ( ...skinToneCodes ) ;
318319 }
319320 const variation = fromCodePoints ( emojiCodes ) ;
320- match [ "subtitle" ] = keyword /*+ " " + toCodePointString(emojiCodes) */ ;
321+ match [ "subtitle" ] = ( keyword ? keyword : "" ) /*+ " " + toCodePointString(emojiCodes) */ ;
321322 match [ "icon" ] = variation ;
322323 match [ "actionArgument" ] [ "variation" ] = variation ;
323324 }
0 commit comments