mike-fabian / ibus-typing-booster

ibus-typing-booster is a completion input method for faster typing
https://mike-fabian.github.io/ibus-typing-booster/
Other
233 stars 15 forks source link

[BUG] When an m17n input method produces NFD, the cursor position after committing with space may be wrong. #515

Closed mike-fabian closed 5 months ago

mike-fabian commented 5 months ago

This input method https://github.com/mike-fabian/m17n-db-ipa-x-sampa/blob/main/ipa-x-sampa.mim#L114 sometimes produces NFD output, for example when typing e_H the output is e U+0065 LATIN SMALL LETTER E followed by U+0301 COMBINING ACUTE ACCENT.

ibus-typing-booster always uses NFC for the display of the preedit and always commits everything converted to NFC.

so when typing e _ H space, then a é U+00E9 LATIN SMALL LETTER E WITH ACUTE is commited.

When the commit happend, the cursor displayed in the preedit was at the end of the string é, i.e. at position 1 in a string with length 1, i.e. at the right end of the preedit. So no cursor position correction should be done between commiting the é and committing or forwarding the space.

But the current cursor position correction mistakenly uses the NFD version of the commit string, which has length 2. So it tries to "correct" the cursor position by moving one step left after commiting the é which puts the cursor before the é and then the space is inserted before the é .

mike-fabian commented 5 months ago

See this video:

https://github.com/mike-fabian/ibus-typing-booster/assets/2330175/8d0d6cd7-1598-4de2-80f7-20f3679cc6c8