mirror of
https://github.com/wez/wezterm.git
synced 2024-09-11 14:25:57 +03:00
fix: send correct codes with del and esc
With kitty keyboard protocol enabled, both DEL and ESC key sends legacy keys - DEL sends ^H and ESC sends ^[. To be in line with kitty keyboard protocol, they should send "CSI 3 ~" and "CSI 27 u" respectively.
This commit is contained in:
parent
22f9f8d288
commit
855957ec82
@ -1648,8 +1648,9 @@ impl KeyEvent {
|
||||
{
|
||||
// Check for simple text generating keys
|
||||
match &self.key {
|
||||
// Don't send legacy codes with DEL and ESC
|
||||
Char('\x1b') | Char('\x7f') => {}
|
||||
Char('\x08') => return '\x7f'.to_string(),
|
||||
Char('\x7f') => return '\x08'.to_string(),
|
||||
Char(c) => return c.to_string(),
|
||||
_ => {}
|
||||
}
|
||||
@ -3124,4 +3125,57 @@ mod test {
|
||||
"\u{1b}[102;14u".to_string()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn encode_issue_4785() {
|
||||
let flags = KittyKeyboardFlags::DISAMBIGUATE_ESCAPE_CODES;
|
||||
|
||||
assert_eq!(
|
||||
KeyEvent {
|
||||
key: KeyCode::Char('\x7f'),
|
||||
modifiers: Modifiers::NONE,
|
||||
leds: KeyboardLedStatus::empty(),
|
||||
repeat_count: 1,
|
||||
key_is_down: true,
|
||||
raw: None,
|
||||
#[cfg(windows)]
|
||||
win32_uni_char: None,
|
||||
}
|
||||
.encode_kitty(flags),
|
||||
"\u{1b}[3;1~".to_string()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
make_event_with_raw(
|
||||
KeyEvent {
|
||||
key: KeyCode::Char('\x7f'),
|
||||
modifiers: Modifiers::NONE,
|
||||
leds: KeyboardLedStatus::empty(),
|
||||
repeat_count: 1,
|
||||
key_is_down: true,
|
||||
raw: None,
|
||||
#[cfg(windows)]
|
||||
win32_uni_char: None,
|
||||
},
|
||||
Some(PhysKeyCode::KeypadDelete)
|
||||
)
|
||||
.encode_kitty(flags),
|
||||
"\x1b[57426;1u".to_string()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
KeyEvent {
|
||||
key: KeyCode::Char('\x1b'),
|
||||
modifiers: Modifiers::NONE,
|
||||
leds: KeyboardLedStatus::empty(),
|
||||
repeat_count: 1,
|
||||
key_is_down: true,
|
||||
raw: None,
|
||||
#[cfg(windows)]
|
||||
win32_uni_char: None,
|
||||
}
|
||||
.encode_kitty(flags),
|
||||
"\u{1b}[27;1u".to_string()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user