Skip to content

Temporarily disable input method interception.#159699

Merged
alexdima merged 8 commits intomicrosoft:mainfrom
guttyon:temporarily_disable_input_method_interception
Nov 18, 2022
Merged

Temporarily disable input method interception.#159699
alexdima merged 8 commits intomicrosoft:mainfrom
guttyon:temporarily_disable_input_method_interception

Conversation

@guttyon
Copy link
Contributor

@guttyon guttyon commented Aug 31, 2022

Fixes #151496
Fixes #72176
This fix for Windows only, not for Linux .
This fix uses ffi-napi win32 ImmGetContext ImmReleaseContext ImmSetOpenStatus ImmGetOpenStatus GetFocus.

This fix adds the following steps.

  1. Disable IME when hit ctrl-k.
  2. The next key press is not intercepted because IME is disabled and is passed directly to vscode.
  3. Enable IME on subsequent keystroke.

Copy link
Member

@alexdima alexdima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tackling this with system calls seems to be taking a very big hammer to try to fix this problem. Have you explored calling .preventDefault() in the compositionstart event when chords are active here --

this._register(this._textArea.onCompositionStart((e) => {

@guttyon
Copy link
Contributor Author

guttyon commented Sep 23, 2022

Thanks for the advice.
I did not know about preventDefault, so I tried calling it in onKeyDown and onCompositionStart.
When called in onKeyDown, English input was disabled on the vscode as expected, but contrary to expectations, Japanese input was possible.
When invoked with onCompositionStart, both English and Japanese input was possible. I could not tell if these behaviors are in accordance with the specification.
I wish there was a better way because I too think it is a big hammer.

guttyon and others added 3 commits October 28, 2022 04:44
rebase, sync fork
Author:    guttyon <danmarikimari@gmail.com>
interactive rebase in progress; onto 851a0da
Last command done (1 command done):
   pick e021b16 Temporarily disable input method interception. fixes microsoft#151496
Next command to do (1 remaining command):
   pick 07b3ec4be36 add keybindingChordMode. move ime code into if-closure in _leaveChordMode. Because original code is called multi time while typing key.
You are currently rebasing branch 'temporarily_disable_input_method_interception' on '851a0dad5dd'.
…Mode. Because original code is called multi time while typing key.
@guttyon guttyon force-pushed the temporarily_disable_input_method_interception branch from e021b16 to 476520d Compare October 27, 2022 19:46
@guttyon
Copy link
Contributor Author

guttyon commented Oct 27, 2022

Since preventDefault does not seem to avoid interception by IME, I thought of another means.

In the end, we ended up adding two lines as follows
https://github.com/microsoft/vscode/pull/159699/files#

We decided to use the extension for IME operation and eliminated it from vscode.
Register the keybindingChordMode command in the extension to get events that manipulate the IME.
https://github.com/guttyon/vscode-extension-toggle-ime-in-chordmode

This pull request eliminates the need to turn the IME off and back on again when using shortcut keys.

@alexdima alexdima self-requested a review November 16, 2022 13:34
@alexdima
Copy link
Member

@guttyon I've explored a different technique, to make all editors readonly when in chord mode. Having them be readonly seems to be a good way to suppress composition from starting. This works well for me on macOS, could you please give this a try on Windows?

@alexdima alexdima added this to the November 2022 milestone Nov 18, 2022
@alexdima alexdima merged commit 2635da4 into microsoft:main Nov 18, 2022
@guttyon
Copy link
Contributor Author

guttyon commented Nov 19, 2022

@alexdima
It worked on windows,ubuntu22.04.
It is very comfortable.
I think the method using readonly is excellent because it doesn't need to be supported for each ime.
Thank you very much for your efforts on this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The waiting second key is intercepted by the input method Some keyboard shortcuts do not work when use IME

4 participants