engine: an emoji query shows as typed and Space picks

The emoji search folded the keys for its lookup and then showed and
committed the folded copy: SMILE became smile in the text.  And it
showed the transliteration only while that alone matched, so a Korean
query flipped between 웃 and key soup as it grew.  Now the query shown
is the keys while they match anything, else what they type in the
current language, both as typed; only the lookups fold.  Space in a
search picks the highlighted result as Enter does, instead of adding a
space no alias needs.
This commit is contained in:
2026-08-17 01:44:29 +09:00
parent bab40c95a7
commit 0c4271b8b5
3 changed files with 17 additions and 10 deletions

View File

@@ -560,30 +560,34 @@ transstr(Lang *l, Str *pre, Str *raw, Str *out)
commitim(&q, out);
}
/* The typed keys and their transliteration are both emoji queries. */
/*
* The typed keys and their transliteration are both emoji queries, folded
* as the dictionary is; the query shown is the keys while they match
* something, else the transliteration, as typed.
*/
static void
emojiquery(void)
{
Str kouho[Maxkouho], raw, local;
int i, n, rawhit, localhit;
int i, n, rawhit;
raw = search.raw;
foldascii(&raw);
transstr(im.l, nil, &search.raw, &local);
transstr(im.l, nil, &search.raw, &search.text);
local = search.text;
foldascii(&local);
clearkouho();
n = dictprefix(getlang(LangEMOJI)->dict, &raw, kouho, Maxkouho);
rawhit = n != 0;
for(i = 0; i < n; i++)
addkouho(&kouho[i]);
localhit = 0;
if(scmp(&raw, &local) != 0){
n = dictprefix(getlang(LangEMOJI)->dict, &local, kouho, Maxkouho);
localhit = n != 0;
for(i = 0; i < n; i++)
addkouho(&kouho[i]);
}
search.text = rawhit || !localhit ? raw : local;
if(rawhit)
search.text = search.raw;
selectfirst();
}
@@ -706,7 +710,7 @@ searchkey(u32int ks, u32int mod, Str *com)
cyclekouho(mod & Mshift ? -1 : 1);
return 1;
}
if(ks == Kret){
if(ks == Kret || ks == ' '){
if(im.nkouho > 0)
picksearch(max(im.sel, 0), com);
else