mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-05 10:20:51 +00:00
Embed match index inside of search query editor
This commit is contained in:
parent
13f42550c9
commit
a6bdb6dc5d
3 changed files with 57 additions and 49 deletions
|
@ -75,35 +75,12 @@ impl View for SearchBar {
|
|||
} else {
|
||||
theme.search.editor.container
|
||||
};
|
||||
Flex::row()
|
||||
.with_child(
|
||||
Flex::row()
|
||||
.with_child(
|
||||
ChildView::new(&self.query_editor)
|
||||
.contained()
|
||||
.with_style(editor_container)
|
||||
.aligned()
|
||||
.constrained()
|
||||
.with_max_width(theme.search.max_editor_width)
|
||||
.boxed(),
|
||||
)
|
||||
.with_child(
|
||||
Flex::row()
|
||||
.with_child(self.render_search_option(
|
||||
"Case",
|
||||
SearchOption::CaseSensitive,
|
||||
cx,
|
||||
))
|
||||
.with_child(self.render_search_option("Word", SearchOption::WholeWord, cx))
|
||||
.with_child(self.render_search_option("Regex", SearchOption::Regex, cx))
|
||||
.contained()
|
||||
.with_style(theme.search.option_button_group)
|
||||
.aligned()
|
||||
.boxed(),
|
||||
)
|
||||
.with_child(
|
||||
Flex::row()
|
||||
.with_child(self.render_nav_button("<", Direction::Prev, cx))
|
||||
.with_child(self.render_nav_button(">", Direction::Next, cx))
|
||||
.aligned()
|
||||
.flexible(1., true)
|
||||
.boxed(),
|
||||
)
|
||||
.with_children(self.active_editor.as_ref().and_then(|editor| {
|
||||
|
@ -122,6 +99,34 @@ impl View for SearchBar {
|
|||
.boxed(),
|
||||
)
|
||||
}))
|
||||
.contained()
|
||||
.with_style(editor_container)
|
||||
.aligned()
|
||||
.constrained()
|
||||
.with_max_width(theme.search.max_editor_width)
|
||||
.boxed(),
|
||||
)
|
||||
.with_child(
|
||||
Flex::row()
|
||||
.with_child(self.render_nav_button("<", Direction::Prev, cx))
|
||||
.with_child(self.render_nav_button(">", Direction::Next, cx))
|
||||
.aligned()
|
||||
.boxed(),
|
||||
)
|
||||
.with_child(
|
||||
Flex::row()
|
||||
.with_child(self.render_search_option(
|
||||
"Case",
|
||||
SearchOption::CaseSensitive,
|
||||
cx,
|
||||
))
|
||||
.with_child(self.render_search_option("Word", SearchOption::WholeWord, cx))
|
||||
.with_child(self.render_search_option("Regex", SearchOption::Regex, cx))
|
||||
.contained()
|
||||
.with_style(theme.search.option_button_group)
|
||||
.aligned()
|
||||
.boxed(),
|
||||
)
|
||||
.named("search bar")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -570,9 +570,28 @@ impl ProjectSearchView {
|
|||
} else {
|
||||
theme.search.editor.container
|
||||
};
|
||||
Flex::row()
|
||||
.with_child(
|
||||
Flex::row()
|
||||
.with_child(
|
||||
ChildView::new(&self.query_editor)
|
||||
.flexible(1., true)
|
||||
.boxed(),
|
||||
)
|
||||
.with_children(self.active_match_index.map(|match_ix| {
|
||||
Label::new(
|
||||
format!(
|
||||
"{}/{}",
|
||||
match_ix + 1,
|
||||
self.model.read(cx).match_ranges.len()
|
||||
),
|
||||
theme.search.match_index.text.clone(),
|
||||
)
|
||||
.contained()
|
||||
.with_style(theme.search.match_index.container)
|
||||
.aligned()
|
||||
.boxed()
|
||||
}))
|
||||
.contained()
|
||||
.with_style(editor_container)
|
||||
.aligned()
|
||||
|
@ -580,6 +599,13 @@ impl ProjectSearchView {
|
|||
.with_max_width(theme.search.max_editor_width)
|
||||
.boxed(),
|
||||
)
|
||||
.with_child(
|
||||
Flex::row()
|
||||
.with_child(self.render_nav_button("<", Direction::Prev, cx))
|
||||
.with_child(self.render_nav_button(">", Direction::Next, cx))
|
||||
.aligned()
|
||||
.boxed(),
|
||||
)
|
||||
.with_child(
|
||||
Flex::row()
|
||||
.with_child(self.render_option_button("Case", SearchOption::CaseSensitive, cx))
|
||||
|
@ -590,29 +616,6 @@ impl ProjectSearchView {
|
|||
.aligned()
|
||||
.boxed(),
|
||||
)
|
||||
.with_children({
|
||||
self.active_match_index.into_iter().flat_map(|match_ix| {
|
||||
[
|
||||
Flex::row()
|
||||
.with_child(self.render_nav_button("<", Direction::Prev, cx))
|
||||
.with_child(self.render_nav_button(">", Direction::Next, cx))
|
||||
.aligned()
|
||||
.boxed(),
|
||||
Label::new(
|
||||
format!(
|
||||
"{}/{}",
|
||||
match_ix + 1,
|
||||
self.model.read(cx).match_ranges.len()
|
||||
),
|
||||
theme.search.match_index.text.clone(),
|
||||
)
|
||||
.contained()
|
||||
.with_style(theme.search.match_index.container)
|
||||
.aligned()
|
||||
.boxed(),
|
||||
]
|
||||
})
|
||||
})
|
||||
.contained()
|
||||
.with_style(theme.workspace.toolbar.container)
|
||||
.constrained()
|
||||
|
|
|
@ -392,7 +392,7 @@ extends = "$search.option_button"
|
|||
background = "$surface.2"
|
||||
|
||||
[search.match_index]
|
||||
extends = "$text.1"
|
||||
extends = "$text.2"
|
||||
padding = 6
|
||||
|
||||
[search.editor]
|
||||
|
|
Loading…
Reference in a new issue