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

When non-English IME is active, keyboard shortcuts are also interpreted by IME #615

Closed
achimnol opened this issue Apr 2, 2021 · 6 comments
Labels
bug Something isn't working macOS Issue applies to Apple macOS

Comments

@achimnol
Copy link

achimnol commented Apr 2, 2021

Describe the bug

Regardless of use_ime configuration, when the system IME switches to a non-English keyboard layout (e.g., Korean Sebeolsik), all keyboard shortcuts becomes unusable because IME intercepts them.

Maybe related with #318, though IME is highly platform-specific one.

Environment (please complete the following information):

  • OS: macOS
  • Version: wezterm 20210314-114017-04b7cedd-120-g217dbfb9
  • The active keyboard layout name (eg: ENG, DEU and so on): ENG / Korean Sebeolsik

To Reproduce

Switch the system IME to a non-English layout and try to use keyboard shortcuts that have different key mappings in that layout.
For example, Cmd+1 to switch to the first tab should work regardless of the IME state, but in the Korean Sebulsik (3-beolsik) layout, "1" becomes "ᇂ" and the shortcut does not work.

Configuration

local wezterm = require 'wezterm';

return {
    use_ime = true,  -- the bug is reproducible with false as well!
    color_scheme = "Andromeda",
    font = wezterm.font_with_fallback({
        "JetBrains Mono",
        "Menlo",
        "NanumBarunGothic",
    }),
}

Expected behavior

Normally, keyboard shortcuts should bypass the IME and interpreted as-is.

@achimnol achimnol added the bug Something isn't working label Apr 2, 2021
@wez wez added the macOS Issue applies to Apple macOS label Apr 3, 2021
@achimnol
Copy link
Author

achimnol commented Apr 7, 2021

Another related issue found: Alt key as modifier does not work with use_ime = true and send_composed_key_when_left_alt_is_pressed=false.
For instance, I'd like to use tmux pane resizing with PREFIX, Alt + Up/Down keystrokes.

@achimnol
Copy link
Author

achimnol commented Apr 28, 2021

Function keys (F1, F2, ..., F12) do not work when use_ime=true.
I could workaround this by mapping Shift + Fx to xterm function key sequences, for example, {key="F1", mods="SHIFT", action=wezterm.action{SendString="\x1bOP"}}, but I'd like to use the function keys without disabling IME and without extra modifiers.

When use_ime=true, pressing the function keys results the followings in the debug-keys output:

UNHANDLED: do_command_by_selector: "noop:"
UNHANDLED: do_command_by_selector: "complete:"

@wez
Copy link
Owner

wez commented Dec 31, 2021

Some of what you've described sounds similar to #1409 for which I pushed a fix just now, so hopefully things are now slightly better. There are still a number of things to work out with the IME on macOS; it's slow going because the IME APIs aren't really intended to be used outside of standard macOS text input, and that is at-odds with the text input functionality that terminal users desire!

wez added a commit that referenced this issue Dec 31, 2021
Certain keys are "handled" by the IME through it generating a "noop"
command.

That's not super useful for us, so this commit detects the noop case
and then treats it as though the IME didn't handle the input event.

While implementing the above fix, I realized that the same technique
could be used more generally to return processing to our main input
handling for the various selectors that we do recognize: we were
essentially inferring the original key combinations based on the
selector which is not scalable and potentially lossy.

We can't capture CTRL-ESC this same way, as that key combination
is magical and is routed to the callback without generating any
key events.

refs: #615
refs: #975
refs: #1410
@achimnol
Copy link
Author

I commented out temporary workaround configs, and now the nightly version works as expected, including on-the-spot text composition and functions keys without modifiers! (with just use_ime=true and appropriate fallback font configs)
I can close the issue now. 😄

@wez
Copy link
Owner

wez commented Jan 10, 2022

I'm very interested to hear your opinion on whether we can set use_ime=true by default on macOS after you've worked with the nightly for a couple of days and had a chance to trip over any remaining issues :-)

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working macOS Issue applies to Apple macOS
Projects
None yet
Development

No branches or pull requests

2 participants