diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 371037e0478f62d0edd084470388c331ef29d586..7cce3c71c6c1b61ee0679be22d8e4260dc73a17d 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -470,6 +470,26 @@ impl SearchActionsRegistrar for DivRegistrar<'_, '_, T> { }); } } + +/// Register actions for an active pane. +impl SearchActionsRegistrar for Workspace { + fn register_handler( + &mut self, + callback: fn(&mut BufferSearchBar, &A, &mut ViewContext), + ) { + self.register_action(move |workspace, action: &A, cx| { + let pane = workspace.active_pane(); + pane.update(cx, move |this, cx| { + this.toolbar().update(cx, move |this, cx| { + if let Some(search_bar) = this.item_of_type::() { + search_bar.update(cx, move |this, cx| callback(this, action, cx)); + cx.notify(); + } + }) + }); + }); + } +} impl BufferSearchBar { pub fn register_inner(registrar: &mut impl SearchActionsRegistrar) { registrar.register_handler(|this, action: &ToggleCaseSensitive, cx| { @@ -529,24 +549,6 @@ impl BufferSearchBar { }) } fn register(workspace: &mut Workspace) { - impl SearchActionsRegistrar for Workspace { - fn register_handler( - &mut self, - callback: fn(&mut BufferSearchBar, &A, &mut ViewContext), - ) { - self.register_action(move |workspace, action: &A, cx| { - let pane = workspace.active_pane(); - pane.update(cx, move |this, cx| { - this.toolbar().update(cx, move |this, cx| { - if let Some(search_bar) = this.item_of_type::() { - search_bar.update(cx, move |this, cx| callback(this, action, cx)); - cx.notify(); - } - }) - }); - }); - } - } Self::register_inner(workspace); } pub fn new(cx: &mut ViewContext) -> Self {