search: Fix project search not rendering matches count (#36238)

Lukas Wirth created

Follow up to https://github.com/zed-industries/zed/pull/36103/

Release Notes:

- N/A

Change summary

crates/search/src/project_search.rs | 87 +++++++++++++++---------------
1 file changed, 44 insertions(+), 43 deletions(-)

Detailed changes

crates/search/src/project_search.rs 🔗

@@ -1975,6 +1975,48 @@ impl Render for ProjectSearchBar {
                     ),
             );
 
+        let query_focus = search.query_editor.focus_handle(cx);
+
+        let matches_column = h_flex()
+            .pl_2()
+            .ml_2()
+            .border_l_1()
+            .border_color(theme_colors.border_variant)
+            .child(render_action_button(
+                "project-search-nav-button",
+                IconName::ChevronLeft,
+                search.active_match_index.is_some(),
+                "Select Previous Match",
+                &SelectPreviousMatch,
+                query_focus.clone(),
+            ))
+            .child(render_action_button(
+                "project-search-nav-button",
+                IconName::ChevronRight,
+                search.active_match_index.is_some(),
+                "Select Next Match",
+                &SelectNextMatch,
+                query_focus,
+            ))
+            .child(
+                div()
+                    .id("matches")
+                    .ml_2()
+                    .min_w(rems_from_px(40.))
+                    .child(Label::new(match_text).size(LabelSize::Small).color(
+                        if search.active_match_index.is_some() {
+                            Color::Default
+                        } else {
+                            Color::Disabled
+                        },
+                    ))
+                    .when(limit_reached, |el| {
+                        el.tooltip(Tooltip::text(
+                            "Search limits reached.\nTry narrowing your search.",
+                        ))
+                    }),
+            );
+
         let mode_column = h_flex()
             .gap_1()
             .min_w_64()
@@ -2016,55 +2058,14 @@ impl Render for ProjectSearchBar {
                 "Toggle Replace",
                 &ToggleReplace,
                 focus_handle.clone(),
-            ));
-
-        let query_focus = search.query_editor.focus_handle(cx);
-
-        let matches_column = h_flex()
-            .pl_2()
-            .ml_2()
-            .border_l_1()
-            .border_color(theme_colors.border_variant)
-            .child(render_action_button(
-                "project-search-nav-button",
-                IconName::ChevronLeft,
-                search.active_match_index.is_some(),
-                "Select Previous Match",
-                &SelectPreviousMatch,
-                query_focus.clone(),
             ))
-            .child(render_action_button(
-                "project-search-nav-button",
-                IconName::ChevronRight,
-                search.active_match_index.is_some(),
-                "Select Next Match",
-                &SelectNextMatch,
-                query_focus,
-            ))
-            .child(
-                div()
-                    .id("matches")
-                    .ml_2()
-                    .min_w(rems_from_px(40.))
-                    .child(Label::new(match_text).size(LabelSize::Small).color(
-                        if search.active_match_index.is_some() {
-                            Color::Default
-                        } else {
-                            Color::Disabled
-                        },
-                    ))
-                    .when(limit_reached, |el| {
-                        el.tooltip(Tooltip::text(
-                            "Search limits reached.\nTry narrowing your search.",
-                        ))
-                    }),
-            );
+            .child(matches_column);
 
         let search_line = h_flex()
             .w_full()
             .gap_2()
             .child(query_column)
-            .child(h_flex().min_w_64().child(mode_column).child(matches_column));
+            .child(mode_column);
 
         let replace_line = search.replace_enabled.then(|| {
             let replace_column = input_base_styles(InputPanel::Replacement)