WIP: project search redesign

This commit is contained in:
Piotr Osiewicz 2023-07-27 11:43:32 +02:00
parent 129e711545
commit 91c32ed307

View file

@ -505,6 +505,7 @@ impl ProjectSearchView {
Some(Arc::new(|theme| theme.search.editor.input.clone())), Some(Arc::new(|theme| theme.search.editor.input.clone())),
cx, cx,
); );
editor.set_placeholder_text("Text search all files", cx);
editor.set_text(query_text, cx); editor.set_text(query_text, cx);
editor editor
}); });
@ -1230,19 +1231,11 @@ impl View for ProjectSearchBar {
.flex(1.0, true); .flex(1.0, true);
let row_spacing = theme.workspace.toolbar.container.padding.bottom; let row_spacing = theme.workspace.toolbar.container.padding.bottom;
let query = ChildView::new(&search.query_editor, cx)
Flex::column()
.with_child(
Flex::row()
.with_child(
Flex::row()
.with_child(
ChildView::new(&search.query_editor, cx)
.aligned() .aligned()
.left() .left()
.flex(1., true), .flex(1., true);
) let matches = search.active_match_index.map(|match_ix| {
.with_children(search.active_match_index.map(|match_ix| {
Label::new( Label::new(
format!( format!(
"{}/{}", "{}/{}",
@ -1254,7 +1247,21 @@ impl View for ProjectSearchBar {
.contained() .contained()
.with_style(theme.search.match_index.container) .with_style(theme.search.match_index.container)
.aligned() .aligned()
})) .left()
});
let case_button = self.render_option_button("Case", SearchOptions::CASE_SENSITIVE, cx);
let word_button = self.render_option_button("Word", SearchOptions::WHOLE_WORD, cx);
let regex_button = self.render_option_button("Regex", SearchOptions::REGEX, cx);
let semantic_index =
SemanticIndex::enabled(cx).then(|| self.render_semantic_search_button(cx));
Flex::column()
.with_child(
Flex::row()
.with_children(matches)
.with_child(
Flex::row()
.with_child(query)
.contained() .contained()
.with_style(query_container_style) .with_style(query_container_style)
.aligned() .aligned()
@ -1269,35 +1276,17 @@ impl View for ProjectSearchBar {
.with_child(self.render_nav_button(">", Direction::Next, cx)) .with_child(self.render_nav_button(">", Direction::Next, cx))
.aligned(), .aligned(),
) )
.with_child({ .with_child(
let row = if SemanticIndex::enabled(cx) {
Flex::row().with_child(self.render_semantic_search_button(cx))
} else {
Flex::row() Flex::row()
}; .with_children(semantic_index)
.with_child(case_button)
let row = row .with_child(word_button)
.with_child(self.render_option_button( .with_child(regex_button)
"Case",
SearchOptions::CASE_SENSITIVE,
cx,
))
.with_child(self.render_option_button(
"Word",
SearchOptions::WHOLE_WORD,
cx,
))
.with_child(self.render_option_button(
"Regex",
SearchOptions::REGEX,
cx,
))
.contained() .contained()
.with_style(theme.search.option_button_group) .with_style(theme.search.option_button_group)
.aligned(); .aligned()
.right(),
row )
})
.contained() .contained()
.with_margin_bottom(row_spacing), .with_margin_bottom(row_spacing),
) )
@ -1328,8 +1317,7 @@ impl View for ProjectSearchBar {
) )
.contained() .contained()
.with_style(theme.search.container) .with_style(theme.search.container)
.aligned() .flex_float()
.left()
.into_any_named("project search") .into_any_named("project search")
} else { } else {
Empty::new().into_any() Empty::new().into_any()