From 761428dbc4f0894b4bc07a46ca6d83d5ca74de42 Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Tue, 18 Aug 2026 16:20:18 +0900 Subject: [PATCH] engine: a Hanja word shows once, as every other candidate does MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hanjaquery was the only query that assigned dictprefix's output straight into im.kouho; emojiquery, dictqjp and katakouho all go through addkouho, which is the only place a duplicate is dropped. Two readings under one prefix can carry the same word, and 198 of the 61,479 one- and two-syllable prefixes in hanja.dict do: 게 listed 偈句 at rows 8 and 9, 개근 listed 皆勤狀 twice in five. Co-Authored-By: Claude Opus 5 (1M context) --- strans.c | 8 +++++--- tests/engine_test.c | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/strans.c b/strans.c index 21d199d..ade368e 100644 --- a/strans.c +++ b/strans.c @@ -653,14 +653,16 @@ emojiquery(void) static void hanjaquery(void) { - Str tail; + Str kouho[Maxkouho], tail; + int i, n; transstr(im.l, &search.seed, &search.raw, &tail); search.text = search.back; sappend(&search.text, &tail); clearkouho(); - im.nkouho = dictprefix(getlang(LangHANJA)->dict, &search.text, - im.kouho, Maxkouho); + n = dictprefix(getlang(LangHANJA)->dict, &search.text, kouho, Maxkouho); + for(i = 0; i < n; i++) + addkouho(&kouho[i]); selectfirst(); } diff --git a/tests/engine_test.c b/tests/engine_test.c index c3b2dd9..2c3e60d 100644 --- a/tests/engine_test.c +++ b/tests/engine_test.c @@ -2072,6 +2072,8 @@ engine_hanja_word_prefix(struct ct *t) Str com; hanjabegin(&f, LangKO); + /* Two readings under one prefix may share a word; it shows once. */ + setdict(f.dictlang->dict, "민민", "民"); sclear(&com); if(!CT_CHECK(t, keystroke('h', Mctrl, &com)) || !typekeys(t, "als", &com))