fix(engine): the search keys commit the query they end or replace

Ctrl+E during an emoji search, Ctrl+H during a hanja search, or either
during the other search dropped the typed query, while every other
Ctrl key committed it as the README says. Escape is the way to cancel;
the search keys now commit the shown text like a language switch.
This commit is contained in:
2026-08-16 20:27:31 +09:00
parent 6402c26830
commit 32a9723043
2 changed files with 30 additions and 16 deletions

View File

@@ -556,15 +556,6 @@ endsearch(void)
clearkouho();
}
/* A search commits any pending composition and takes over the keys. */
static void
startsearch(int lang, Str *com)
{
commit(com);
endsearch();
search.lang = lang;
}
static void
commitsearch(Str *com)
{
@@ -572,6 +563,15 @@ commitsearch(Str *com)
endsearch();
}
/* A search commits whatever is pending and takes over the keys. */
static void
startsearch(int lang, Str *com)
{
commit(com);
commitsearch(com);
search.lang = lang;
}
static void
picksearch(int n, Str *com)
{
@@ -639,15 +639,12 @@ searchkey(u32int ks, u32int mod, Str *com)
if(mod & Mctrl){
c = ctrlkey(ks);
n = searchlang(c);
if(n == search.lang)
endsearch();
else if(n != 0)
if(n != 0 && n != search.lang){
startsearch(n, com);
else{
commitsearch(com);
return setlang(c);
return 1;
}
return 1;
commitsearch(com);
return n != 0 || setlang(c);
}
if(search.raw.n >= Maxrunes){
commitsearch(com);

View File

@@ -1585,6 +1585,23 @@ engine_emoji_start_and_unknown(struct ct *t)
im.l = getlang(LangKO);
}
/* So do the search keys, ending or changing the search. */
sclear(&com);
CT_CHECK(t, keystroke('e', Mctrl, &com));
if(typekeys(t, "xy", &com)){
CT_CHECK(t, keystroke('e', Mctrl, &com));
checkstr(t, "search key commits query", "xy", &com);
CT_CHECK(t, !search.lang);
}
sclear(&com);
CT_CHECK(t, keystroke('e', Mctrl, &com));
if(typekeys(t, "xy", &com)){
CT_CHECK(t, keystroke('h', Mctrl, &com));
checkstr(t, "other search commits query", "xy", &com);
CT_EQ_INT(t, LangHANJA, search.lang);
CT_CHECK(t, keystroke(Kesc, 0, &com));
}
sclear(&com);
CT_CHECK(t, keystroke('e', Mctrl, &com));
for(i = 0; i < Maxrunes; i++)