From 5927f6a5e1847ba99481cf787fc4031834db5f61 Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Wed, 12 Aug 2026 16:21:33 +0900 Subject: [PATCH] fix: forward input at the composition limit --- strans.c | 4 +++- tests/engine_test.c | 30 ++++++++++++++++++++++++++++++ tests/test.h | 1 + tests/unit_test.c | 1 + 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/strans.c b/strans.c index 26efc2c..b47a609 100644 --- a/strans.c +++ b/strans.c @@ -718,8 +718,10 @@ keystroke(u32int ks, u32int mod, Str *com) if(!haspre(&im)) return 0; commit(com); - sputr(com, ks); reset(); + if(com->n >= Maxrunes) + return 0; + sputr(com, ks); return 1; } if(im.l->trans == nil) diff --git a/tests/engine_test.c b/tests/engine_test.c index 246ae2f..88542dc 100644 --- a/tests/engine_test.c +++ b/tests/engine_test.c @@ -1280,3 +1280,33 @@ engine_randomized_stress(struct ct *t) emojiend(&f); vi->map = vimap; } + +void +engine_full_boundary_passthrough(struct ct *t) +{ + Str com; + int i; + + init(); + im.l = getlang(LangJP); + for(i = 0; i < Maxrunes; i++) + im.pre.r[i] = L'あ'; + im.pre.n = Maxrunes; + sclear(&com); + CT_CHECK(t, !keystroke(' ', 0, &com)); + CT_EQ_INT(t, Maxrunes, com.n); + for(i = 0; i < Maxrunes; i++) + CT_EQ_UINT(t, L'あ', com.r[i]); + CT_EQ_INT(t, 0, im.pre.n); + CT_EQ_INT(t, 0, im.raw.n); + + init(); + im.l = getlang(LangJP); + for(i = 0; i < Maxrunes-1; i++) + im.pre.r[i] = L'あ'; + im.pre.n = Maxrunes-1; + sclear(&com); + CT_CHECK(t, keystroke(' ', 0, &com)); + CT_EQ_INT(t, Maxrunes, com.n); + CT_EQ_UINT(t, ' ', com.r[Maxrunes-1]); +} diff --git a/tests/test.h b/tests/test.h index bff84af..107b207 100644 --- a/tests/test.h +++ b/tests/test.h @@ -61,6 +61,7 @@ void engine_emoji_preedit_languages(struct ct*); void engine_emoji_start_and_unknown(struct ct*); void engine_emoji_dictionary_identity(struct ct*); void engine_randomized_stress(struct ct*); +void engine_full_boundary_passthrough(struct ct*); void dictionary_candidates(struct ct*); void dictionary_misses_clear_result(struct ct*); void dictionary_emoji_identity(struct ct*); diff --git a/tests/unit_test.c b/tests/unit_test.c index 508df79..64e6fc8 100644 --- a/tests/unit_test.c +++ b/tests/unit_test.c @@ -110,6 +110,7 @@ static const struct ct_test tests[] = { { "engine/emoji-start-and-unknown", engine_emoji_start_and_unknown }, { "engine/emoji-dictionary-identity", engine_emoji_dictionary_identity }, { "engine/randomized-stress", engine_randomized_stress }, + { "engine/full-boundary-passthrough", engine_full_boundary_passthrough }, { "dict/candidates", dictionary_candidates }, { "dict/misses-clear-result", dictionary_misses_clear_result }, { "dict/emoji-identity", dictionary_emoji_identity },