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

Wezterm may send different keys than kitty with kitty protocol enabled #4785

Open
gessen opened this issue Jan 13, 2024 · 3 comments · May be fixed by #5025
Open

Wezterm may send different keys than kitty with kitty protocol enabled #4785

gessen opened this issue Jan 13, 2024 · 3 comments · May be fixed by #5025
Labels
bug Something isn't working

Comments

@gessen
Copy link

gessen commented Jan 13, 2024

What Operating System(s) are you seeing this problem on?

Linux X11

Which Wayland compositor or X11 Window manager(s) are you using?

KWin

WezTerm version

20230712-072601-f4abf8fd

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

Running emacs in terminal mode (emacs -nw) with kpp package (https://github.com/benjaminor/kkp, listed here https://sw.kovidgoyal.net/kitty/keyboard-protocol/), with Kitty Keyboard Protocol enabled, wezterm sends C-h instead of DEL when pressing DEL key. This doesn't reproduce with kitty itself with the same configuration on emacs side. It also doesn't reproduce with wezterm on MacOS.

To Reproduce

Minimal emacs configuration (~/.config/emacs/init.el):

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-install 'kkp)
(require 'kkp)
(global-kkp-mode +1)

Run emacs with emacs -nw, use C-x b RET to switch to writable buffer, write some random text, move to the beginning of the line and press DEL twice to remove 2 chars in front of the cursor. With kitty two characters are removed as expected, with wizterm function help-for-help is invoked which is bound to C-h C-h

Configuration

config = {}
config.enable_kitty_keyboard = true
return config

Expected Behavior

No response

Logs

Debug Overlay
wezterm version: 20230712-072601-f4abf8fd x86_64-unknown-linux-gnu
Window Environment: X11 KWin
OpenGL: AMD Radeon RX 6950 XT (radeonsi, navi21, LLVM 16.0.6, DRM 3.54, 6.6.10-arch1-1) 4.6 (Compatibility Profile) Mesa 23.3.3-arch1.1

Logs from pressing DELETE while in emacs:

11:49:00.732  INFO   wezterm_gui::termwindow::keyevent     > key_event RawKeyEvent { key: Physical(Delete), modifiers: NONE, leds: NUM_LOCK, phys_code: Some(Delete), raw_code: 119, repeat_count: 1,key_is_down: true, handled: Handled(false) }
11:49:00.732  INFO   wezterm_gui::termwindow::keyevent     > key_event KeyEvent { key: Char('\u{7f}'), modifiers: NONE, leds: NUM_LOCK, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(Delete), modifiers: NONE, leds: NUM_LOCK, phys_code: Some(Delete), raw_code: 119, repeat_count: 1, key_is_down: true, handled: Handled(false) }) }
11:49:00.732  INFO   wezterm_gui::termwindow::keyevent     > kitty: Encoded input as "\u{8}"
11:49:00.769  INFO   wezterm_gui::termwindow::keyevent     > key_event KeyEvent { key: Char('\u{7f}'), modifiers: NONE, leds: NUM_LOCK, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(Delete), modifiers: NONE, leds: NUM_LOCK, phys_code: Some(Delete), raw_code: 119, repeat_count: 1, key_is_down: false, handled: Handled(false) }) }
11:49:00.769  INFO   wezterm_gui::termwindow::keyevent     > kitty: Encoded input as ""

Anything else?

No response

@gessen gessen added the bug Something isn't working label Jan 13, 2024
@gessen
Copy link
Author

gessen commented Jan 13, 2024

A quicker reproduction:

printf '\033[>1u' && showkey -a

With kitty the output after pressing DEL key is:

^[[3;129~ 	27 0033 0x1b
 	91 0133 0x5b
 	51 0063 0x33
 	59 0073 0x3b
 	49 0061 0x31
 	50 0062 0x32
 	57 0071 0x39
 	126 0176 0x7e

With wezterm it's:

^H        8 0010 0x08

@gessen
Copy link
Author

gessen commented Jan 13, 2024

I think the problem lies in this early matcher. If I remove early returns for both backspace and DEL then the later logic will handle it correctly compared to kitty output (DEL logic and backspace logic).

diff --git i/wezterm-input-types/src/lib.rs w/wezterm-input-types/src/lib.rs
index b3298bad6..5bf150e1b 100644
--- i/wezterm-input-types/src/lib.rs
+++ w/wezterm-input-types/src/lib.rs
@@ -1648,8 +1648,8 @@ impl KeyEvent {
         {
             // Check for simple text generating keys
             match &self.key {
-                Char('\x08') => return '\x7f'.to_string(),
-                Char('\x7f') => return '\x08'.to_string(),
+                Char('\x08') => {},
+                Char('\x7f') => {},
                 Char(c) => return c.to_string(),
                 _ => {}
             }

@AThePeanut4
Copy link

I believe this is a duplicate of #3621. I made that issue when I ran into the same issue with the Delete key, only in Neovim, and I've just been working around it by remapping <C-H> to <Del> inside Neovim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants