1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-11 13:51:01 -05:00

Don't emit text for NamedKey without text repr

When the key doesn't have textual representation we shouldn't emit
the text for them, since they are processed via bindings.

Also, fix the logic to handle named keys with disambiguate without
special modes/modifiers.

Fixes #7423.
This commit is contained in:
Kirill Chibisov 2023-12-08 09:28:50 +04:00 committed by GitHub
parent 1a143d11d3
commit e12c750edb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -107,15 +107,19 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {
mods: ModifiersState,
) -> bool {
if mode.contains(TermMode::REPORT_ALL_KEYS_AS_ESC) {
true
} else if mode.contains(TermMode::DISAMBIGUATE_ESC_CODES) {
let on_numpad = key.location == KeyLocation::Numpad;
let is_escape = key.logical_key == Key::Named(NamedKey::Escape);
is_escape || (!mods.is_empty() && mods != ModifiersState::SHIFT) || on_numpad
} else {
// `Delete` key always has text attached to it, but it's a named key, thus needs to be
// excluded here as well.
text.is_empty() || key.logical_key == Key::Named(NamedKey::Delete)
return true;
}
let disambiguate = mode.contains(TermMode::DISAMBIGUATE_ESC_CODES)
&& (key.logical_key == Key::Named(NamedKey::Escape)
|| (!mods.is_empty() && mods != ModifiersState::SHIFT)
|| key.location == KeyLocation::Numpad);
match key.logical_key {
_ if disambiguate => true,
// Exclude all the named keys unless they have textual representation.
Key::Named(named) => named.to_text().is_none(),
_ => text.is_empty(),
}
}