From dfcf9a2b168931b7ab9479a5754404a6e4e07ecb Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Tue, 22 Jul 2025 13:56:37 -0400 Subject: [PATCH] keymap_ui: Fix panic in clear keystrokes (cherry-pick #34909) (#34913) Cherry-picked keymap_ui: Fix panic in clear keystrokes (#34909) Closes #ISSUE Release Notes: - N/A *or* Added/Fixed/Improved ... Co-authored-by: Ben Kunkle --- crates/settings_ui/src/keybindings.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/settings_ui/src/keybindings.rs b/crates/settings_ui/src/keybindings.rs index bcb06ec172e54750e83b3aa5de6f477ce129b9bc..01eddba39566fe4066aa97d6e866e67c8bc3b4e8 100644 --- a/crates/settings_ui/src/keybindings.rs +++ b/crates/settings_ui/src/keybindings.rs @@ -2784,6 +2784,7 @@ impl KeystrokeInput { else { log::trace!("No keybinding to stop recording keystrokes in keystroke input"); self.close_keystrokes.take(); + self.close_keystrokes_start.take(); return CloseKeystrokeResult::None; }; let action_keystrokes = keybind_for_close_action.keystrokes(); @@ -2976,7 +2977,9 @@ impl KeystrokeInput { return; } window.focus(&self.outer_focus_handle); - if let Some(close_keystrokes_start) = self.close_keystrokes_start.take() { + if let Some(close_keystrokes_start) = self.close_keystrokes_start.take() + && close_keystrokes_start < self.keystrokes.len() + { self.keystrokes.drain(close_keystrokes_start..); } self.close_keystrokes.take();