diff --git a/crates/settings_ui/src/keybindings.rs b/crates/settings_ui/src/keybindings.rs index 0db288fe5a..af096f4ce1 100644 --- a/crates/settings_ui/src/keybindings.rs +++ b/crates/settings_ui/src/keybindings.rs @@ -304,7 +304,7 @@ impl KeymapEditor { let keystroke_editor = cx.new(|cx| { let mut keystroke_editor = KeystrokeInput::new(None, window, cx); - keystroke_editor.highlight_on_focus = false; + keystroke_editor.search = true; keystroke_editor }); @@ -1036,18 +1036,16 @@ impl KeymapEditor { self.search_mode = self.search_mode.invert(); self.on_query_changed(cx); - // Update the keystroke editor to turn the `search` bool on - self.keystroke_editor.update(cx, |keystroke_editor, cx| { - keystroke_editor - .set_search_mode(matches!(self.search_mode, SearchMode::KeyStroke { .. })); - cx.notify(); - }); - match self.search_mode { SearchMode::KeyStroke { .. } => { window.focus(&self.keystroke_editor.read(cx).recording_focus_handle(cx)); } - SearchMode::Normal => {} + SearchMode::Normal => { + self.keystroke_editor.update(cx, |editor, cx| { + editor.clear_keystrokes(&ClearKeystrokes, window, cx) + }); + window.focus(&self.filter_editor.focus_handle(cx)); + } } } @@ -2419,7 +2417,6 @@ enum KeyPress<'a> { struct KeystrokeInput { keystrokes: Vec, placeholder_keystrokes: Option>, - highlight_on_focus: bool, outer_focus_handle: FocusHandle, inner_focus_handle: FocusHandle, intercept_subscription: Option, @@ -2447,7 +2444,6 @@ impl KeystrokeInput { Self { keystrokes: Vec::new(), placeholder_keystrokes, - highlight_on_focus: true, inner_focus_handle, outer_focus_handle, intercept_subscription: None, @@ -2666,10 +2662,6 @@ impl KeystrokeInput { self.inner_focus_handle.clone() } - fn set_search_mode(&mut self, search: bool) { - self.search = search; - } - fn start_recording(&mut self, _: &StartRecording, window: &mut Window, cx: &mut Context) { if !self.outer_focus_handle.is_focused(window) { return; @@ -2829,7 +2821,7 @@ impl Render for KeystrokeInput { .track_focus(&self.inner_focus_handle) .on_modifiers_changed(cx.listener(Self::on_modifiers_changed)) .size_full() - .when(self.highlight_on_focus, |this| { + .when(!self.search, |this| { this.focus(|mut style| { style.border_color = Some(colors.border_focused); style