engine: Backspace deletes the last kana shown; Tab converts like Space

Backspace undid a keystroke: な became ん, かんじ became かんj, きゃ
became ky.  Like every Japanese IME it now deletes the last kana as
shown — な goes, かんじ becomes かん, きゃ becomes き — while a romaji
letter that never became kana still goes one at a time.  Tab stepped
through candidates in a search and committed in Japanese; it steps
through them there too, with Space, and Shift+Tab steps back.
This commit is contained in:
2026-08-17 01:55:25 +09:00
parent a03fb05324
commit e32cea3296
3 changed files with 51 additions and 32 deletions

View File

@@ -120,9 +120,9 @@ engine_backspace_clears_candidates(struct ct *t)
checkstr(t, "chosen candidate backspace", "na", &im.raw);
CT_CHECK(t, keystroke(Kback, 0, &com));
checkstr(t, "backspace commit", "", &com);
checkstr(t, "pending romaji after backspace", "n", &im.raw);
checkstr(t, "backspace deletes the kana shown", "", &im.raw);
impre(&im, &shown);
checkstr(t, "shown preedit after backspace", "", &shown);
checkstr(t, "shown preedit after backspace", "", &shown);
CT_EQ_INT(t, 0, im.nkouho);
CT_EQ_INT(t, -1, im.sel);
}
@@ -852,21 +852,28 @@ engine_candidate_page_movement(struct ct *t)
void
engine_candidate_completion(struct ct *t)
{
static Rune keys[] = { Kret, Ktab };
Str com;
int i;
for(i = 0; i < nelem(keys); i++){
init();
im.l = getlang(LangJP);
im.pre = mkstr("reading");
setcandidates(1);
sclear(&com);
CT_CHECK(t, keystroke(keys[i], 0, &com));
checkstr(t, "unselected candidate commits reading",
"reading", &com);
CT_EQ_INT(t, 0, im.nkouho);
}
init();
im.l = getlang(LangJP);
im.pre = mkstr("reading");
setcandidates(1);
sclear(&com);
CT_CHECK(t, keystroke(Kret, 0, &com));
checkstr(t, "unselected candidate commits reading", "reading", &com);
CT_EQ_INT(t, 0, im.nkouho);
init();
im.l = getlang(LangJP);
im.pre = mkstr("reading");
setcandidates(2);
sclear(&com);
CT_CHECK(t, keystroke(Ktab, 0, &com));
CT_EQ_INT(t, 0, im.sel);
CT_CHECK(t, keystroke(Ktab, Mshift, &com));
CT_EQ_INT(t, 1, im.sel);
CT_CHECK(t, keystroke(Kret, 0, &com));
checkstr(t, "Tab steps through the candidates", "c2", &com);
candidatebegin(2);
im.pre = mkstr("reading");
@@ -1250,8 +1257,6 @@ engine_japanese_candidates(struct ct *t)
if(!typekeys(t, "kanji", &com))
goto cleanup;
CT_CHECK(t, keystroke(Kback, 0, &com));
CT_EQ_INT(t, 0, im.nkouho);
CT_CHECK(t, keystroke(Kback, 0, &com));
if(CT_EQ_INT(t, 1, im.nkouho))
checkstr(t, "shorter reading candidate", "", &im.kouho[0]);
cleanup:
@@ -1270,13 +1275,18 @@ engine_japanese_backspace_and_boundaries(struct ct *t)
if(typekeys(t, "kanji", &com)){
CT_CHECK(t, keystroke(Kback, 0, &com));
impre(&im, &shown);
checkstr(t, "backspace pending i", "かんj", &shown);
checkstr(t, "backspace deletes じ", "かん", &shown);
CT_CHECK(t, keystroke(Kback, 0, &com));
impre(&im, &shown);
checkstr(t, "backspace pending j", "", &shown);
CT_CHECK(t, keystroke(Kback, 0, &com));
impre(&im, &shown);
checkstr(t, "backspace accumulated kana", "", &shown);
checkstr(t, "backspace deletes ん", "", &shown);
if(typekeys(t, "kyu", &com)){
CT_CHECK(t, keystroke(Kback, 0, &com));
impre(&im, &shown);
checkstr(t, "backspace deletes ゅ", "かき", &shown);
CT_CHECK(t, keystroke(Kback, 0, &com));
CT_CHECK(t, keystroke(Kback, 0, &com));
CT_CHECK(t, !haspre(&im));
}
}
init();