1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-30 06:03:39 +03:00

macos: normalize Composed("p") -> Char('p') when use_ime=true

When the IME is enabled, pressing `CTRL-A P` would generate
`Composed("P")` for the second key press, which we couldn't
then match in the keymapping layer.

This commit checks for that and normalizes it to `Char('P')`
instead.

refs: https://github.com/wez/wezterm/issues/1409
refs: https://github.com/wez/wezterm/issues/1410
This commit is contained in:
Wez Furlong 2021-12-30 21:32:35 -07:00
parent 7efc6a6cb8
commit e3afdd7b8f
2 changed files with 16 additions and 1 deletions

View File

@ -66,6 +66,7 @@ As features stabilize some brief notes about them will accumulate here.
* `wezterm ssh` no longer tries to use `default_prog` or `default_cwd` when spawning additional panes on the remote host [#1456](https://github.com/wez/wezterm/issues/1456)
* Launcher menu WSL items now launch correctly on non-US versions of Windows [#1462](https://github.com/wez/wezterm/issues/1462)
* Korean text in NFD form is now correctly sized and rendered [#1474](https://github.com/wez/wezterm/issues/1474)
* macOS: `use_ime=true` conflicted with `LEADER` key assignments [#1409](https://github.com/wez/wezterm/issues/1409)
### 20211205-192649-672c1cc1

View File

@ -1407,8 +1407,22 @@ impl WindowView {
let mut inner = myself.inner.borrow_mut();
let key_is_down = inner.key_is_down.take().unwrap_or(true);
// Prefer to send along a single Char when the string
// is just a single char, as the keymapping layer cannot
// bind to composed key sequences and we'll get those
// for example when use_ime=true and the user presses
// `CTRL-A p` - we'd get CTRL-A followed by Composed("p")
// here if we didn't normalize it back to Char.
let mut iter = s.chars();
let first_char = iter.next();
let next_char = iter.next();
let key = match (first_char, next_char) {
(Some(c), None) => KeyCode::Char(c),
_ => KeyCode::Composed(s.to_string()),
};
let event = KeyEvent {
key: KeyCode::Composed(s.to_string()),
key,
raw_key: None,
modifiers: Modifiers::NONE,
raw_modifiers: Modifiers::NONE,