diff --git a/README.md b/README.md index f95e1c3..26a9d3e 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,8 @@ adjectives SKK keys by stem and okurigana (かく offers 確 and 書く), and under `Space` the reading in Katakana last, so a word the dictionary lacks converts to Katakana with one `Space`. `Space` or `Tab` chooses the first candidate and then steps on, wrapping (with `Shift`, back); `Up`/`Down` and -`PageUp`/`PageDown` move without wrapping. An unmodified `1`-`9` commits -that row of the current page. `Enter` commits the chosen candidate, or the +`PageUp`/`PageDown` move without wrapping. Once a candidate is chosen, an unmodified `1`-`9` commits that row of the +current page; before that the digits type. `Enter` commits the chosen candidate, or the reading when none is chosen, as `0` always does; so does typing on, or any key that ends the composition. `Backspace` deletes the last kana shown; romaji that made no kana stays in the reading as typed until it is mended. diff --git a/strans.c b/strans.c index 4f45137..6cb868e 100644 --- a/strans.c +++ b/strans.c @@ -812,7 +812,8 @@ transition(u32int ks, u32int mod, Str *com) movekouho(n); return 1; } - n = numberedkouho(ks, mod); + /* Digits pick a candidate only once the list has been engaged. */ + n = im.sel >= 0 ? numberedkouho(ks, mod) : -1; if(n >= 0){ sappend(com, &im.kouho[n]); reset(); diff --git a/tests/engine_test.c b/tests/engine_test.c index c999dab..9ff0ec7 100644 --- a/tests/engine_test.c +++ b/tests/engine_test.c @@ -888,6 +888,20 @@ engine_candidate_completion(struct ct *t) CT_CHECK(t, keystroke(Kret, 0, &com)); checkstr(t, "Enter without candidates", "reading", &com); + /* A digit types on until Space engages the list. */ + candidatebegin(3); + im.pre = mkstr("reading"); + sclear(&com); + CT_CHECK(t, !keystroke('2', 0, &com)); + checkstr(t, "digit before the list is engaged", "reading", &com); + CT_EQ_INT(t, 0, im.nkouho); + candidatebegin(3); + im.pre = mkstr("reading"); + sclear(&com); + CT_CHECK(t, keystroke(' ', 0, &com)); + CT_CHECK(t, keystroke('2', 0, &com)); + checkstr(t, "digit after the list is engaged", "c2", &com); + /* A digit with no such row on the page is an ordinary key: it * confirms the candidate paged to and passes on. */ candidatebegin(32);