From 4d1fbde96e0d7f6ea3dd09c10beffd3c06fc0e0c Mon Sep 17 00:00:00 2001 From: Raphael Amorim Date: Wed, 25 Dec 2024 12:19:45 -0300 Subject: [PATCH] explicitly emit 1 without modifiers in kitty encoding --- docs/docs/releases.md | 1 + frontends/rioterm/src/bindings/kitty_keyboard.rs | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/docs/releases.md b/docs/docs/releases.md index 3744ee7579..1ebac090a7 100644 --- a/docs/docs/releases.md +++ b/docs/docs/releases.md @@ -18,6 +18,7 @@ language: 'en' - Kitty keyboard protocol is now enabled by default. - Allow `Renderer` to be configured cross-platform by `Platform` property. - Add `ToggleFullscreen` to configurable actions. +- Always emit `1` for the first parameter when having modifiers in kitty keyboard protocol. ## 0.2.2 diff --git a/frontends/rioterm/src/bindings/kitty_keyboard.rs b/frontends/rioterm/src/bindings/kitty_keyboard.rs index 43e3d46bce..62bd5bf8ad 100644 --- a/frontends/rioterm/src/bindings/kitty_keyboard.rs +++ b/frontends/rioterm/src/bindings/kitty_keyboard.rs @@ -56,7 +56,7 @@ pub fn build_key_sequence(key: &KeyEvent, mods: ModifiersState, mode: Mode) -> V let sequence_base = context .try_build_numpad(key) .or_else(|| context.try_build_named_kitty(key)) - .or_else(|| context.try_build_named_normal(key)) + .or_else(|| context.try_build_named_normal(&key, associated_text.is_some())) .or_else(|| context.try_build_control_char_or_mod(key, &mut modifiers)) .or_else(|| context.try_build_textual(key, associated_text)); @@ -263,14 +263,21 @@ impl SequenceBuilder { } /// Try building from [`NamedKey`]. - fn try_build_named_normal(&self, key: &KeyEvent) -> Option { + fn try_build_named_normal( + &self, + key: &KeyEvent, + has_associated_text: bool, + ) -> Option { let named = match key.logical_key { Key::Named(named) => named, _ => return None, }; // The default parameter is 1, so we can omit it. - let one_based = if self.modifiers.is_empty() && !self.kitty_event_type { + let one_based = if self.modifiers.is_empty() + && !self.kitty_event_type + && !has_associated_text + { "" } else { "1"