-
Notifications
You must be signed in to change notification settings - Fork 58
Don’t handle or replay keystrokes during IME composition #178
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a sane, nicely pragmatic approach. I do have a couple questions.
|
||
handleCompositionEnd: -> | ||
@compositionInProgress = false | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do these actually get called? The only call sites I see are in specs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They'll have to get called in Atom with some new event handlers.
@@ -622,10 +629,16 @@ class KeymapManager | |||
# event. This means the current event has removed any hope that the queued | |||
# key events will ever match any binding. So we will clear the state and | |||
# start over after replaying the events in `terminatePendingState`. | |||
@terminatePendingState() | |||
@terminatePendingState() if event.type is 'keyup' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reasoning behind this change? I did some testing with my recent changes and it seems to work fine but I couldn't figure out why you added this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because compositionstart
happens after keydown
, we need to wait until keyup to know whether or not replay should be suppressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, duh. Connecting that now with what you said in the PR description. Cool.
@nathansobo I was able to verify both the IME issues look like they are working. #172 for the japanese layout, using atom stable with vim-mode-plus, I was getting extra characters when typing, but works fine with your branch. For the other issue #177 with Chinese Pinyin Layout, it looks like it worked fine in stable, and works with the new build too… did this break in beta? |
@ungb I was testing on the Electron 1.4.x branch. So it could be something with the new Electron version or just my computer. |
I tested the change on atom/atom#13233. I just built his branch and installed it on windows. |
I also want to check with my mac. |
@t9md You should be able to pull a build from Circle CI. Here is the link: https://1886-3228505-gh.circle-artifacts.com/0/Users/distiller/atom/out/atom-mac.zip |
@nathansobo Tried the above link, and result was NOT good.
|
Just in case you want to reproduce it by your side, I think it just installing this google IME and stat IME by I use Mac(EL capitan) with US keyboard with english language environment, so I believe similar environment with you. |
Observed event by this gist. version
1.13.0-beta3 [OK case] without
|
I tested on Windows installing the google IME with version: 1.14.0-dev-a54c4fb from: https://ci.appveyor.com/project/Atom/atom/build/4137/job/cw2tn6wegh563wuh/artifacts Seeing similar issues as you @t9md. Before I was using windows ime, but I'm seeing issues on there now too. I'll follow up with Nathan on his PR: atom/atom#13233 |
@t9md I think I understand what's happening. Even though we aren't replaying keystrokes when the IME is enabled, we still have a problem because we're calling |
If the original event was If you want me do further check, I can do that. |
Looks like we can use the old API and look for a |
That's good, it can work. But how about your original intention, let the Atom set If the event was |
Checked with build in branch 1.13-releases associated with this commit, atom/atom@b77f18c. And result was GOOD, OK, FIXED.
|
Closes #172
Closes #177
In #144, we completely overhauled translation of keyboard events to keystrokes, inadvertently fixing a bug in keystroke resolution that was causing all keystrokes to be recognized as
å
when an IME dialog was visible. Unfortunately, this previous bug was actually a feature in that it prevented any key bindings from matching during an IME editing session. By enabling correct keystroke resolution during IME editing, #144 actually caused interference with the IME user interface... the arrow keys not only change the IME selection, they also move the cursor... enter inserts a new line instead of selecting a character... etc.In addition, replaying input events for previous partial match prefixes yields incorrect behavior when the IME dialog is visible, because in those cases we really want previous keystrokes to combine with new keystrokes to build up a composed character. For now, if we detect that the IME interface is visible, we suppress replay entirely.
Getting IME and multi-stroke bindings to interact perfectly is a really nuanced problem. For example, it's possible that some of the keystrokes need to be replayed but not all of them. Also, what if a partially matched multi-stroke binding prevented the IME interface from popping up to begin with. Since our replay mechanism doesn't work at the browser level (maybe it should?) we won't open the IME dialog in those cases.
Because
compositionstart
events do not occur until afterkeydown
events, I've needed to defer terminating the pending state until thekeyup
event following thekeydown
where we previously terminated. This ensures that thecompositionstart
event has been received so we can suppress replay if a composition is in progress. @iolsen this seems like it will work, but you've had your head wrapped around this system recently as well. Do you foresee any issues I'm missing?For now, I think we should draw the line here. IME users will just need to be careful about conflicts with multi-stroke unmodified bindings. This is a pretty extreme edge case, and going further is going to involve a complete rethink of our approach to replay that we don't have time for right now.