mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-27 16:57:08 +00:00
WIP: project search redesign
This commit is contained in:
parent
129e711545
commit
91c32ed307
1 changed files with 36 additions and 48 deletions
|
@ -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,31 +1231,37 @@ 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)
|
||||||
|
.aligned()
|
||||||
|
.left()
|
||||||
|
.flex(1., true);
|
||||||
|
let matches = search.active_match_index.map(|match_ix| {
|
||||||
|
Label::new(
|
||||||
|
format!(
|
||||||
|
"{}/{}",
|
||||||
|
match_ix + 1,
|
||||||
|
search.model.read(cx).match_ranges.len()
|
||||||
|
),
|
||||||
|
theme.search.match_index.text.clone(),
|
||||||
|
)
|
||||||
|
.contained()
|
||||||
|
.with_style(theme.search.match_index.container)
|
||||||
|
.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()
|
Flex::column()
|
||||||
.with_child(
|
.with_child(
|
||||||
Flex::row()
|
Flex::row()
|
||||||
|
.with_children(matches)
|
||||||
.with_child(
|
.with_child(
|
||||||
Flex::row()
|
Flex::row()
|
||||||
.with_child(
|
.with_child(query)
|
||||||
ChildView::new(&search.query_editor, cx)
|
|
||||||
.aligned()
|
|
||||||
.left()
|
|
||||||
.flex(1., true),
|
|
||||||
)
|
|
||||||
.with_children(search.active_match_index.map(|match_ix| {
|
|
||||||
Label::new(
|
|
||||||
format!(
|
|
||||||
"{}/{}",
|
|
||||||
match_ix + 1,
|
|
||||||
search.model.read(cx).match_ranges.len()
|
|
||||||
),
|
|
||||||
theme.search.match_index.text.clone(),
|
|
||||||
)
|
|
||||||
.contained()
|
|
||||||
.with_style(theme.search.match_index.container)
|
|
||||||
.aligned()
|
|
||||||
}))
|
|
||||||
.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()
|
||||||
Flex::row().with_child(self.render_semantic_search_button(cx))
|
.with_children(semantic_index)
|
||||||
} else {
|
.with_child(case_button)
|
||||||
Flex::row()
|
.with_child(word_button)
|
||||||
};
|
.with_child(regex_button)
|
||||||
|
|
||||||
let row = row
|
|
||||||
.with_child(self.render_option_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()
|
||||||
|
|
Loading…
Reference in a new issue