From 846ed6adf91fc63f585c921da0101802b031c855 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 15 Aug 2025 14:54:05 +0200 Subject: [PATCH] search: Fix project search not rendering matches count (#36238) Follow up to https://github.com/zed-industries/zed/pull/36103/ Release Notes: - N/A --- crates/search/src/project_search.rs | 87 +++++++++++++++-------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 6b9777906af1791605644c64e3a72f3ddde920d6..b791f748adfcd4714b7853e5701b051f26f09d60 100644 --- a/crates/search/src/project_search.rs +++ b/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)