1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-25 14:22:37 +03:00

kitty keeb: avoid sending function codes in mode 1

refs: #3626
This commit is contained in:
Wez Furlong 2023-04-15 19:15:26 -07:00
parent c544b0edce
commit a562cb5a92
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387

View File

@ -1842,18 +1842,16 @@ impl KeyEvent {
}
_ => {
if self.key.is_modifier()
&& !flags.contains(KittyKeyboardFlags::REPORT_ALL_KEYS_AS_ESCAPE_CODES)
{
// Don't report bare modifier only key events unless
// we're reporting all keys with escape codes
String::new()
} else if let Some(code) =
self.raw.as_ref().and_then(|raw| raw.kitty_function_code())
{
let code = self.raw.as_ref().and_then(|raw| raw.kitty_function_code());
match (
code,
flags.contains(KittyKeyboardFlags::REPORT_ALL_KEYS_AS_ESCAPE_CODES),
) {
(Some(code), true) => {
format!("\x1b[{code};{modifiers}{event_type}{generated_text}u")
} else {
String::new()
}
_ => String::new(),
}
}
}
@ -2652,5 +2650,37 @@ mod test {
.encode_kitty(flags),
" ".to_string()
);
assert_eq!(
make_event_with_raw(
KeyEvent {
key: KeyCode::NumLock,
modifiers: Modifiers::NONE,
leds: KeyboardLedStatus::empty(),
repeat_count: 1,
key_is_down: true,
raw: None
},
Some(PhysKeyCode::NumLock)
)
.encode_kitty(flags),
"".to_string()
);
assert_eq!(
make_event_with_raw(
KeyEvent {
key: KeyCode::CapsLock,
modifiers: Modifiers::NONE,
leds: KeyboardLedStatus::empty(),
repeat_count: 1,
key_is_down: true,
raw: None,
},
Some(PhysKeyCode::CapsLock)
)
.encode_kitty(flags),
"".to_string()
);
}
}