engine: nothing pending is no reading, and reaches into nothing

startsearch let reachback walk the client's text whenever Ctrl+H found
im.sel < 0, without asking whether anything was pending, so a Ctrl+H
pressed to begin a reading took the syllables already written instead.
With the cursor after 입니다 the query became 다, the preedit showed
nothing at all, and Space committed 多 over the 다 the user had written;
typing the reading the key was pressed for gave 다한, so 입니다漢 came
out 입니多恨.  A reading is what is pending, and there is none.

The seeded reach is untouched: 한 committed with 자 pending still
converts 한자 as a word and takes the 한 back.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-18 16:02:27 +09:00
parent cf0eba6642
commit b08f3bb7a2
2 changed files with 19 additions and 1 deletions

View File

@@ -793,7 +793,9 @@ startsearch(int lang, Str *com)
sclear(&seed);
if(lang == LangHANJA && !search.lang && im.sel < 0){
impre(&im, &seed);
reachback(&seed, &back);
/* Nothing pending is no reading, and reaches into nothing. */
if(seed.n != 0)
reachback(&seed, &back);
}else
flush(com);
reset();

View File

@@ -2005,6 +2005,22 @@ engine_hanja_reaches_back(struct ct *t)
CT_EQ_INT(t, 0, takeback);
}
/* Nothing pending is no reading, and reaches into nothing. */
surround = mkstr("");
sclear(&im.pre);
sclear(&com);
CT_CHECK(t, keystroke('h', Mctrl, &com));
CT_EQ_INT(t, 0, search.back.n);
CT_EQ_INT(t, 0, im.nkouho);
if(typekeys(t, "als", &com)){
checkstr(t, "the reading typed is the whole query", "",
&search.text);
CT_CHECK(t, keystroke(Kret, 0, &com));
checkstr(t, "the client's syllable is not converted", "",
&com);
CT_EQ_INT(t, 0, takeback);
}
/* The frontend's own request carries the text and is told to take it. */
init();
im.l = getlang(LangKO);