Bind actions on the whole search bar, not just the query editor

Piotr Osiewicz created

Change summary

crates/search2/src/project_search.rs | 64 +++++++++++++++---------------
1 file changed, 32 insertions(+), 32 deletions(-)

Detailed changes

crates/search2/src/project_search.rs 🔗

@@ -1732,42 +1732,10 @@ impl Render for ProjectSearchBar {
                 h_stack()
                     .min_w_80()
                     .on_action(cx.listener(|this, action, cx| this.confirm(action, cx)))
-                    .on_action(cx.listener(|this, _: &ToggleFilters, cx| {
-                        this.toggle_filters(cx);
-                    }))
-                    .on_action(cx.listener(|this, _: &ToggleWholeWord, cx| {
-                        this.toggle_search_option(SearchOptions::WHOLE_WORD, cx);
-                    }))
-                    .on_action(cx.listener(|this, _: &ToggleCaseSensitive, cx| {
-                        this.toggle_search_option(SearchOptions::CASE_SENSITIVE, cx);
-                    }))
-                    .on_action(cx.listener(|this, action, cx| {
-                        this.toggle_replace(action, cx);
-                    }))
-                    .on_action(cx.listener(|this, _: &ActivateTextMode, cx| {
-                        this.activate_search_mode(SearchMode::Text, cx)
-                    }))
-                    .on_action(cx.listener(|this, _: &ActivateRegexMode, cx| {
-                        this.activate_search_mode(SearchMode::Regex, cx)
-                    }))
                     .on_action(
                         cx.listener(|this, action, cx| this.previous_history_query(action, cx)),
                     )
                     .on_action(cx.listener(|this, action, cx| this.next_history_query(action, cx)))
-                    .on_action(cx.listener(|this, action, cx| {
-                        if let Some(search) = this.active_project_search.as_ref() {
-                            search.update(cx, |this, cx| {
-                                this.replace_next(action, cx);
-                            })
-                        }
-                    }))
-                    .on_action(cx.listener(|this, action, cx| {
-                        if let Some(search) = this.active_project_search.as_ref() {
-                            search.update(cx, |this, cx| {
-                                this.replace_all(action, cx);
-                            })
-                        }
-                    }))
                     .child(IconElement::new(Icon::MagnifyingGlass))
                     .child(search.query_editor.clone())
                     .child(
@@ -1937,6 +1905,38 @@ impl Render for ProjectSearchBar {
             .p_1()
             .m_2()
             .justify_between()
+            .on_action(cx.listener(|this, _: &ToggleFilters, cx| {
+                this.toggle_filters(cx);
+            }))
+            .on_action(cx.listener(|this, _: &ToggleWholeWord, cx| {
+                this.toggle_search_option(SearchOptions::WHOLE_WORD, cx);
+            }))
+            .on_action(cx.listener(|this, _: &ToggleCaseSensitive, cx| {
+                this.toggle_search_option(SearchOptions::CASE_SENSITIVE, cx);
+            }))
+            .on_action(cx.listener(|this, action, cx| {
+                this.toggle_replace(action, cx);
+            }))
+            .on_action(cx.listener(|this, _: &ActivateTextMode, cx| {
+                this.activate_search_mode(SearchMode::Text, cx)
+            }))
+            .on_action(cx.listener(|this, _: &ActivateRegexMode, cx| {
+                this.activate_search_mode(SearchMode::Regex, cx)
+            }))
+            .on_action(cx.listener(|this, action, cx| {
+                if let Some(search) = this.active_project_search.as_ref() {
+                    search.update(cx, |this, cx| {
+                        this.replace_next(action, cx);
+                    })
+                }
+            }))
+            .on_action(cx.listener(|this, action, cx| {
+                if let Some(search) = this.active_project_search.as_ref() {
+                    search.update(cx, |this, cx| {
+                        this.replace_all(action, cx);
+                    })
+                }
+            }))
             .child(query_column)
             .child(mode_column)
             .child(replace_column)