ueno / libskk

Japanese SKK input method library
GNU General Public License v3.0
78 stars 27 forks source link

Custom typing rule is not used during dict edit #49

Closed lo48576 closed 6 years ago

lo48576 commented 6 years ago

Assume that using the keymap rule (keymap/default.json) below:

{
    "define": {
        "keymap": {
            "C-g": null,
            "C-c": "abort",
            "C-r": "abort",
            ...
        }
    }
}

Type "P o y o SPC", and you will see ▼ぽよ【】 appears. Then:

At ▽ぽよ state, C-g does nothing and both C-c and C-g work as expected (input cancelled).

Why C-g is treated specially?


Additional note in Japanese: 端的な説明: https://mastodon.cardina1.red/@lo48576/99383492999038223

47, #48 を利用して "Escape": "abort-to-latin-passthrough" のように設定することで vi-cooperative にしたかったのですが、そもそも辞書登録状態で abort が期待したように動いてなさそうだったため issue を立てました。

私もコードを読んでみたのですが、 C-g をハードコーディングで特別扱いしている箇所は見付からなかったため、何故このような挙動になっているのかわかりませんでした。 何らかの仕掛けで、辞書登録時に "abort" コマンドでなく "C-g" キーのみが影響を及ぼすようになっているのでしょうか?

lo48576 commented 6 years ago

Rule I set by rom-kana seems not used during dict edit. I think the problem is that the custom rule is not used during dict edit.

lo48576 commented 6 years ago

https://github.com/ueno/libskk/blob/afe959be545d92137377d5e78ef366540ad3bac9/libskk/context.vala#L353-L354 https://github.com/ueno/libskk/blob/afe959be545d92137377d5e78ef366540ad3bac9/libskk/state.vala#L132-L142

When entering to dict edit mode, a new state is created and pushed, but the new state is created with default rule by default. This seems to be causing the issue.

I'll write pull request to fix this soon.

ueno commented 6 years ago

Right, thank you for investigating it. I guess the fix itself would be trivial (adding state.typing_rule = typing_rule in start_dict_edit), but it would be great if we have a test case too.