Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add a new button for the action
Kirill Bulatovb14cd5f56d30
diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rsindex c3790116d34..f6466c85af3 100644--- a/crates/search/src/buffer_search.rs+++ b/crates/search/src/buffer_search.rs@@ -148,6 +148,7 @@ impl View for BufferSearchBar {Flex::row().with_child(self.render_nav_button("<", Direction::Prev, cx)).with_child(self.render_nav_button(">", Direction::Next, cx))+ .with_child(self.render_action_button("Select All", cx)).aligned(),).with_child(@@ -403,6 +404,37 @@ impl BufferSearchBar {.into_any()}+ fn render_action_button(+ &self,+ icon: &'static str,+ cx: &mut ViewContext<Self>,+ ) -> AnyElement<Self> {+ let tooltip = "Select All Matches";+ let tooltip_style = theme::current(cx).tooltip.clone();+ let action_type_id = 0_usize;++ enum ActionButton {}+ MouseEventHandler::<ActionButton, _>::new(action_type_id, cx, |state, cx| {+ let theme = theme::current(cx);+ let style = theme.search.action_button.style_for(state);+ Label::new(icon, style.text.clone())+ .contained()+ .with_style(style.container)+ })+ .on_click(MouseButton::Left, move |_, this, cx| {+ this.select_all_matches(&SelectAllMatches, cx)+ })+ .with_cursor_style(CursorStyle::PointingHand)+ .with_tooltip::<ActionButton>(+ action_type_id,+ tooltip.to_string(),+ Some(Box::new(SelectAllMatches)),+ tooltip_style,+ cx,+ )+ .into_any()+ }+fn render_close_button(&self,theme: &theme::Search,diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rsindex 4e8ece1c8fc..cdf3cadf594 100644--- a/crates/theme/src/theme.rs+++ b/crates/theme/src/theme.rs@@ -379,6 +379,7 @@ pub struct Search {pub invalid_include_exclude_editor: ContainerStyle,pub include_exclude_inputs: ContainedText,pub option_button: Toggleable<Interactive<ContainedText>>,+ pub action_button: Interactive<ContainedText>,pub match_background: Color,pub match_index: ContainedText,pub results_status: TextStyle,