Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

keymap_ui: Fix panic in clear keystrokes (#34909)

Ben Kunkle14cea06f0fb5
diff --git a/crates/settings_ui/src/keybindings.rs b/crates/settings_ui/src/keybindings.rs
index 5f940e8a25c..9e885f69f6e 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();