Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Move Registrar implementation for Workspace to outer scope.
Piotr Osiewicz783256c80e62
diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rsindex 371037e0478..7cce3c71c6c 100644--- a/crates/search/src/buffer_search.rs+++ b/crates/search/src/buffer_search.rs@@ -470,6 +470,26 @@ impl<T: 'static> SearchActionsRegistrar for DivRegistrar<'_, '_, T> {});}}++/// Register actions for an active pane.+impl SearchActionsRegistrar for Workspace {+ fn register_handler<A: Action>(+ &mut self,+ callback: fn(&mut BufferSearchBar, &A, &mut ViewContext<BufferSearchBar>),+ ) {+ 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::<BufferSearchBar>() {+ 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<A: Action>(- &mut self,- callback: fn(&mut BufferSearchBar, &A, &mut ViewContext<BufferSearchBar>),- ) {- 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::<BufferSearchBar>() {- search_bar.update(cx, move |this, cx| callback(this, action, cx));- cx.notify();- }- })- });- });- }- }Self::register_inner(workspace);}pub fn new(cx: &mut ViewContext<Self>) -> Self {