Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrectly handle insertText (macOS) #3925

Open
ksqsf opened this issue Sep 20, 2024 · 0 comments
Open

incorrectly handle insertText (macOS) #3925

ksqsf opened this issue Sep 20, 2024 · 0 comments
Labels
B - bug Dang, that shouldn't have happened DS - macos

Comments

@ksqsf
Copy link

ksqsf commented Sep 20, 2024

Description

Description

Currently, the implementation of insertText is insufficient to cover some input methods that can commit text without setting a preedit. (e.g. when the input method translates a certain key and directly commits the translation.)

Known affected downstream programs include Alacritty and Neovide.

Examples

  • A typical example is the full-width punctuation. If you hit the period key with the input method enabled, it will commit to the program without ever setting a preedit.
  • Another example is SKK-style Japanese input methods, with which, e.g. a directly commits without any preedit. Currently, both full-width punctuation and SKK Japanese input method doesn't work properly.

Analysis

Upon inspection, I found that insertText will only commit text when there is a preedit. (Hence the description above.)

I removed the condition and it almost worked for me. However, it seems to be added in commit 3fd7384 for a good reason.

// Commit only if we have marked text.
if unsafe { self.hasMarkedText() } && self.is_ime_enabled() && !is_control {
self.queue_event(WindowEvent::Ime(Ime::Preedit(String::new(), None)));
self.queue_event(WindowEvent::Ime(Ime::Commit(string)));
self.ivars().ime_state.set(ImeState::Committed);
}

Notes

By "almost" above, I mean it's still not fully satisfactory.

  • On startup, the IME is disabled and only gets enabled after a preedit is set once. That is, for full-width punctuation to work, one has to input something to enter the IME state. For SKK, the situation could get a bit problematic. This should also be fixed. (I think this probably belongs to a separate issue? It could be fixed by setting Ground to be the default. But I might be missing some details here.)
  • Some input methods support toggle keys. For example, in SKK, q toggles Hiragana and Katagana input. If I removed the preedit check, whenever I type q, the input method can receive q (toggling katagana) and another q will also be forwarded to the application.

Another thing is that I noticed the system input methods can commit full-width punctuation just fine. But to my surprise I didn't manage to find any difference in the logs. So I don't really understand what's going on.

macOS version

ProductName:		macOS
ProductVersion:		15.0
BuildVersion:		24A335

Winit version

0.30.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened DS - macos
Development

No branches or pull requests

1 participant