From 2e2d0a3884e16846329a2b31db11e2f5aca5e5ab Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Tue, 1 Aug 2023 17:07:21 +0200 Subject: [PATCH] Hide whole word/case sensitive options under semantic search --- crates/search/src/project_search.rs | 46 +++++++++++++++++++---------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 443ccbd567cdc5e5de76d43882205b3c01cb2a40..497085f75e82a0d5704c56b1ad4c15d0a3e5f527 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -1360,13 +1360,37 @@ impl View for ProjectSearchBar { .with_tooltip::(0, "Toggle filters".into(), None, tooltip_style, cx) .into_any() }; + let search = _search.read(cx); + let is_semantic_disabled = search.semantic.is_none(); + + let case_sensitive = if is_semantic_disabled { + Some(self.render_option_button_icon( + "icons/word_search_12.svg", + SearchOptions::CASE_SENSITIVE, + cx, + )) + } else { + None + }; + + let whole_word = if is_semantic_disabled { + Some(self.render_option_button_icon( + "icons/word_search_12.svg", + SearchOptions::WHOLE_WORD, + cx, + )) + } else { + None + }; + let search = _search.read(cx); let query = Flex::row() .with_child( - Svg::new("icons/magnifying_glass_12.svg").with_color(gpui::color::Color::white()) + Svg::new("icons/magnifying_glass_12.svg") + .with_color(gpui::color::Color::white()) //.with_color(tab_theme.label.text.color) - .contained().constrained() - //.with_margin_right(tab_theme.spacing), + .contained() + .constrained(), //.with_margin_right(tab_theme.spacing), ) .with_child( ChildView::new(&search.query_editor, cx) @@ -1376,19 +1400,9 @@ impl View for ProjectSearchBar { ) .with_child( Flex::row() - .with_children([ - filter_button, - self.render_option_button_icon( - "icons/word_search_12.svg", - SearchOptions::CASE_SENSITIVE, - cx, - ), - self.render_option_button_icon( - "icons/word_search_12.svg", - SearchOptions::WHOLE_WORD, - cx, - ), - ]) + .with_child(filter_button) + .with_children(whole_word) + .with_children(case_sensitive) .flex(1., true) .contained(), )