From e12c750edb776ace9d7f6d302786f5dd06d6e968 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Fri, 8 Dec 2023 09:28:50 +0400 Subject: [PATCH] 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. --- alacritty/src/input/keyboard.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/alacritty/src/input/keyboard.rs b/alacritty/src/input/keyboard.rs index 94633cb1..9db67f42 100644 --- a/alacritty/src/input/keyboard.rs +++ b/alacritty/src/input/keyboard.rs @@ -107,15 +107,19 @@ impl> Processor { 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(), } }