Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
buffer: use shared func for nav button rendering
Piotr Osiewiczf978acdd3408
diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rsindex d7add915998..25149012c7d 100644--- a/crates/search/src/buffer_search.rs+++ b/crates/search/src/buffer_search.rs@@ -1,5 +1,7 @@use crate::{- history::SearchHistory, mode::SearchMode, search_bar::render_search_mode_button,+ history::SearchHistory,+ mode::SearchMode,+ search_bar::{render_nav_button, render_search_mode_button},NextHistoryQuery, PreviousHistoryQuery, SearchOptions, SelectAllMatches, SelectNextMatch,SelectPrevMatch, ToggleCaseSensitive, ToggleWholeWord,};@@ -201,6 +203,17 @@ impl View for BufferSearchBar {.aligned(),)});+ let nav_button_for_direction = |label, direction, cx: &mut ViewContext<Self>| {+ render_nav_button(+ label,+ direction,+ move |_, this, cx| match direction {+ Direction::Prev => this.select_prev_match(&Default::default(), cx),+ Direction::Next => this.select_next_match(&Default::default(), cx),+ },+ cx,+ )+ };Flex::row().with_child(Flex::column()@@ -209,8 +222,8 @@ impl View for BufferSearchBar {.align_children_center().with_child(Flex::row()- .with_child(self.render_nav_button("<", Direction::Prev, cx))- .with_child(self.render_nav_button(">", Direction::Next, cx))+ .with_child(nav_button_for_direction("<", Direction::Prev, cx))+ .with_child(nav_button_for_direction(">", Direction::Next, cx)).aligned(),).with_children(match_count)diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rsindex 611fd028466..b607848e214 100644--- a/crates/search/src/project_search.rs+++ b/crates/search/src/project_search.rs@@ -1550,19 +1550,18 @@ impl View for ProjectSearchBar {};let semantic_index = SemanticIndex::enabled(cx).then(|| search_button_for_mode(SearchMode::Semantic, cx));- let nav_button_for_direction =- |label, direction, cx: &mut ViewContext<ProjectSearchBar>| {- render_nav_button(- label,- direction,- move |_, this, cx| {- if let Some(search) = this.active_project_search.as_ref() {- search.update(cx, |search, cx| search.select_match(direction, cx));- }- },- cx,- )- };+ let nav_button_for_direction = |label, direction, cx: &mut ViewContext<Self>| {+ render_nav_button(+ label,+ direction,+ move |_, this, cx| {+ if let Some(search) = this.active_project_search.as_ref() {+ search.update(cx, |search, cx| search.select_match(direction, cx));+ }+ },+ cx,+ )+ };Flex::row().with_child(