From b08f3bb7a21648740fcc67e2755235d9509ea781 Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Tue, 18 Aug 2026 16:02:27 +0900 Subject: [PATCH] engine: nothing pending is no reading, and reaches into nothing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- strans.c | 4 +++- tests/engine_test.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/strans.c b/strans.c index ce4b52f..6135023 100644 --- a/strans.c +++ b/strans.c @@ -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(); diff --git a/tests/engine_test.c b/tests/engine_test.c index 30d8ec0..c9468dd 100644 --- a/tests/engine_test.c +++ b/tests/engine_test.c @@ -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);