From 0fdc162f8f0686342d4a78dc55a6cc916bc69998 Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Fri, 13 Jun 2025 09:50:06 +0200 Subject: [PATCH] handle `search::FocusSearch` action --- Cargo.lock | 1 + crates/settings_ui/Cargo.toml | 1 + crates/settings_ui/src/keybindings.rs | 17 +++++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 42fa8fa3b4e2e901f9da3688f19346e56f2c2679..92cec5d4e10d708c33d8da67fcc452ba7369e9e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14580,6 +14580,7 @@ dependencies = [ "paths", "project", "schemars", + "search", "serde", "settings", "theme", diff --git a/crates/settings_ui/Cargo.toml b/crates/settings_ui/Cargo.toml index 2e7622d1686fc8f73c1f510bb3eabcfb0b18b553..591dd8acaa99932112c9e78c2d81d7f4c6168cb1 100644 --- a/crates/settings_ui/Cargo.toml +++ b/crates/settings_ui/Cargo.toml @@ -25,6 +25,7 @@ log.workspace = true menu.workspace = true paths.workspace = true project.workspace = true +search.workspace = true schemars.workspace = true serde.workspace = true settings.workspace = true diff --git a/crates/settings_ui/src/keybindings.rs b/crates/settings_ui/src/keybindings.rs index 0948aca8695cf4cc679d0035bb63f5412d2e883f..799a24c4818ddc31f557ef7ba553b6dfc5fc1b30 100644 --- a/crates/settings_ui/src/keybindings.rs +++ b/crates/settings_ui/src/keybindings.rs @@ -207,6 +207,7 @@ impl KeymapEditor { fn dispatch_context(&self, _window: &Window, _cx: &Context) -> KeyContext { let mut dispatch_context = KeyContext::new_with_defaults(); dispatch_context.add("KeymapEditor"); + dispatch_context.add("BufferSearchBar"); dispatch_context.add("menu"); // todo! track key context in keybind edit modal @@ -266,6 +267,21 @@ impl KeymapEditor { cx.notify(); } } + + fn focus_search( + &mut self, + _: &search::FocusSearch, + window: &mut Window, + cx: &mut Context, + ) { + if !self + .filter_editor + .focus_handle(cx) + .contains_focused(window, cx) + { + window.focus(&self.filter_editor.focus_handle(cx)); + } + } } #[derive(Clone)] @@ -295,6 +311,7 @@ impl Render for KeymapEditor { .on_action(cx.listener(Self::select_previous)) .on_action(cx.listener(Self::select_first)) .on_action(cx.listener(Self::select_last)) + .on_action(cx.listener(Self::focus_search)) .size_full() .bg(theme.colors().background) .id("keymap-editor")