diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 4e19d8b11c..6581c3bc01 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -42,12 +42,12 @@ use gpui::{ Action, Along, AnyElement, App, AppContext, AvailableSpace, Axis as ScrollbarAxis, BorderStyle, Bounds, ClickEvent, ContentMask, Context, Corner, Corners, CursorStyle, DispatchPhase, Edges, Element, ElementInputHandler, Entity, Focusable as _, FontId, GlobalElementId, Hitbox, - HitboxBehavior, Hsla, InteractiveElement, IntoElement, IsZero, KeybindingKeystroke, Keystroke, - Length, ModifiersChangedEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, - PaintQuad, ParentElement, Pixels, ScrollDelta, ScrollHandle, ScrollWheelEvent, ShapedLine, - SharedString, Size, StatefulInteractiveElement, Style, Styled, TextRun, TextStyleRefinement, - WeakEntity, Window, anchored, deferred, div, fill, linear_color_stop, linear_gradient, outline, - point, px, quad, relative, size, solid_background, transparent_black, + HitboxBehavior, Hsla, InteractiveElement, IntoElement, IsZero, KeybindingKeystroke, Length, + ModifiersChangedEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, PaintQuad, + ParentElement, Pixels, ScrollDelta, ScrollHandle, ScrollWheelEvent, ShapedLine, SharedString, + Size, StatefulInteractiveElement, Style, Styled, TextRun, TextStyleRefinement, WeakEntity, + Window, anchored, deferred, div, fill, linear_color_stop, linear_gradient, outline, point, px, + quad, relative, size, solid_background, transparent_black, }; use itertools::Itertools; use language::language_settings::{ diff --git a/crates/settings_ui/src/keybindings.rs b/crates/settings_ui/src/keybindings.rs index 253f97d53e..56b55b9416 100644 --- a/crates/settings_ui/src/keybindings.rs +++ b/crates/settings_ui/src/keybindings.rs @@ -1202,7 +1202,7 @@ async fn save_keybinding_update( } struct KeystrokeInput { - keystrokes: Vec, + keystrokes: Vec, focus_handle: FocusHandle, } @@ -1230,10 +1230,14 @@ impl KeystrokeInput { last.modifiers = event.modifiers; } } else { - self.keystrokes.push(Keystroke { + self.keystrokes.push(KeybindingKeystroke { + inner: Keystroke { + modifiers: event.modifiers, + key: "".to_string(), + key_char: None, + }, modifiers: event.modifiers, key: "".to_string(), - key_char: None, }); } cx.stop_propagation(); @@ -1249,12 +1253,13 @@ impl KeystrokeInput { if event.is_held { return; } + let keystroke = event.keystroke.clone().into_keybinding_keystroke(); if let Some(last) = self.keystrokes.last_mut() && last.key.is_empty() { - *last = event.keystroke.clone(); + *last = keystroke; } else { - self.keystrokes.push(event.keystroke.clone()); + self.keystrokes.push(keystroke); } cx.stop_propagation(); cx.notify(); @@ -1266,22 +1271,27 @@ impl KeystrokeInput { _window: &mut Window, cx: &mut Context, ) { + let keystroke = event.keystroke.clone().into_keybinding_keystroke(); if let Some(last) = self.keystrokes.last_mut() && !last.key.is_empty() - && last.modifiers == event.keystroke.modifiers + && last.modifiers == keystroke.modifiers { - self.keystrokes.push(Keystroke { - modifiers: event.keystroke.modifiers, + self.keystrokes.push(KeybindingKeystroke { + inner: Keystroke { + modifiers: event.keystroke.modifiers, + key: "".to_string(), + key_char: None, + }, + modifiers: keystroke.modifiers, key: "".to_string(), - key_char: None, }); } cx.stop_propagation(); cx.notify(); } - fn keystrokes(&self) -> Vec { - let keystrokes = if self + fn keystrokes(&self) -> &[KeybindingKeystroke] { + if self .keystrokes .last() .map_or(false, |last| last.key.is_empty()) @@ -1289,12 +1299,7 @@ impl KeystrokeInput { &self.keystrokes[..self.keystrokes.len() - 1] } else { &self.keystrokes - }; - keystrokes - .to_vec() - .into_iter() - .map(|keystroke| keystroke.into_keybinding_keystroke()) - .collect() + } } }