From 70383b4d16619aed5964fa93b62f6f52a78a8d6f Mon Sep 17 00:00:00 2001 From: KyleBarton Date: Wed, 17 Dec 2025 10:57:33 -0800 Subject: [PATCH] Remove breadcrumbs from project_search; add collapse/expand to its render. Co-authored-by: Danilo Leal --- crates/search/src/project_search.rs | 96 ++++++++++------------------- 1 file changed, 33 insertions(+), 63 deletions(-) diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index be82cbbacf23ea3063e44c4db61896406e9939a8..deab3daec7812eb134c9741210aa3b1ad1d74a2e 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -658,66 +658,6 @@ impl Item for ProjectSearchView { _ => {} } } - - fn breadcrumb_location(&self, _: &App) -> ToolbarItemLocation { - if self.has_matches() { - ToolbarItemLocation::Secondary - } else { - ToolbarItemLocation::Hidden - } - } - - fn breadcrumbs(&self, _theme: &theme::Theme, _cx: &App) -> Option> { - // This should only show the prefix - hence it cannot be none right now - Some(vec![]) - } - - fn breadcrumb_prefix( - &self, - _window: &mut Window, - cx: &mut Context, - ) -> Option { - if !self.has_matches() { - return None; - } - - let is_collapsed = self.results_collapsed; - - let (icon, label, tooltip_label) = if is_collapsed { - ( - IconName::ChevronUpDown, - "Expand All", - "Expand All Search Results", - ) - } else { - ( - IconName::ChevronDownUp, - "Collapse All", - "Collapse All Search Results", - ) - }; - - let focus_handle = self.query_editor.focus_handle(cx); - - Some( - Button::new("project-search-collapse-expand", label) - .icon(icon) - .icon_position(IconPosition::Start) - .icon_size(IconSize::Small) - .tooltip(move |_, cx| { - Tooltip::for_action_in( - tooltip_label, - &ToggleAllSearchResults, - &focus_handle, - cx, - ) - }) - .on_click(cx.listener(|this, _, window, cx| { - this.toggle_all_search_results(&ToggleAllSearchResults, window, cx); - })) - .into_any_element(), - ) - } } impl ProjectSearchView { @@ -2038,10 +1978,10 @@ impl ProjectSearchBar { impl Render for ProjectSearchBar { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let Some(search) = self.active_project_search.clone() else { - return div(); + return div().into_any_element(); }; let search = search.read(cx); - let focus_handle = search.focus_handle(cx); + let focus_handle = search.focus_handle(cx).clone(); let container_width = window.viewport_size().width; let input_width = SearchInputWidth::calc_width(container_width); @@ -2204,9 +2144,38 @@ impl Render for ProjectSearchBar { )) .child(matches_column); + let is_collapsed = search.results_collapsed; + + let (icon, tooltip_label) = if is_collapsed { + (IconName::ChevronUpDown, "Expand All Search Results") + } else { + (IconName::ChevronDownUp, "Collapse All Search Results") + }; + + let tooltip_focus_handle = focus_handle.clone(); + + let expand_button = IconButton::new("project-search-collapse-expand", icon) + .tooltip(move |_, cx| { + Tooltip::for_action_in( + tooltip_label, + &ToggleAllSearchResults, + &tooltip_focus_handle.clone(), + cx, + ) + }) + .on_click(cx.listener(|this, _, window, cx| { + if let Some(active_view) = &this.active_project_search { + active_view.update(cx, |active_view, cx| { + active_view.toggle_all_search_results(&ToggleAllSearchResults, window, cx); + }) + } + })); + let search_line = h_flex() + .pl_1() .w_full() .gap_2() + .child(expand_button) .child(query_column) .child(mode_column); @@ -2325,7 +2294,7 @@ impl Render for ProjectSearchBar { v_flex() .gap_2() - .py(px(1.0)) + .py_px() .w_full() .key_context(key_context) .on_action(cx.listener(|this, _: &ToggleFocus, window, cx| { @@ -2372,6 +2341,7 @@ impl Render for ProjectSearchBar { .children(replace_line) .children(filter_line) .children(filter_error_line) + .into_any_element() } }