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:
29
strans.c
29
strans.c
@@ -556,15 +556,6 @@ endsearch(void)
|
|||||||
clearkouho();
|
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
|
static void
|
||||||
commitsearch(Str *com)
|
commitsearch(Str *com)
|
||||||
{
|
{
|
||||||
@@ -572,6 +563,15 @@ commitsearch(Str *com)
|
|||||||
endsearch();
|
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
|
static void
|
||||||
picksearch(int n, Str *com)
|
picksearch(int n, Str *com)
|
||||||
{
|
{
|
||||||
@@ -639,15 +639,12 @@ searchkey(u32int ks, u32int mod, Str *com)
|
|||||||
if(mod & Mctrl){
|
if(mod & Mctrl){
|
||||||
c = ctrlkey(ks);
|
c = ctrlkey(ks);
|
||||||
n = searchlang(c);
|
n = searchlang(c);
|
||||||
if(n == search.lang)
|
if(n != 0 && n != search.lang){
|
||||||
endsearch();
|
|
||||||
else if(n != 0)
|
|
||||||
startsearch(n, com);
|
startsearch(n, com);
|
||||||
else{
|
return 1;
|
||||||
commitsearch(com);
|
|
||||||
return setlang(c);
|
|
||||||
}
|
}
|
||||||
return 1;
|
commitsearch(com);
|
||||||
|
return n != 0 || setlang(c);
|
||||||
}
|
}
|
||||||
if(search.raw.n >= Maxrunes){
|
if(search.raw.n >= Maxrunes){
|
||||||
commitsearch(com);
|
commitsearch(com);
|
||||||
|
|||||||
@@ -1585,6 +1585,23 @@ engine_emoji_start_and_unknown(struct ct *t)
|
|||||||
im.l = getlang(LangKO);
|
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);
|
sclear(&com);
|
||||||
CT_CHECK(t, keystroke('e', Mctrl, &com));
|
CT_CHECK(t, keystroke('e', Mctrl, &com));
|
||||||
for(i = 0; i < Maxrunes; i++)
|
for(i = 0; i < Maxrunes; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user