Do not display match count when query is empty

This commit is contained in:
Piotr Osiewicz 2023-08-09 01:15:17 +02:00
parent b282bdfe5a
commit a583d1c6cc

View file

@ -178,20 +178,13 @@ impl View for BufferSearchBar {
) )
}) })
}; };
Flex::row() let match_count = self
.with_child( .active_searchable_item
Flex::column() .as_ref()
.with_child( .and_then(|searchable_item| {
Flex::row() if self.query(cx).is_empty() {
.align_children_center() return None;
.with_child( }
Flex::row()
.with_child(self.render_nav_button("<", Direction::Prev, cx))
.with_child(self.render_nav_button(">", Direction::Next, cx))
.aligned(),
)
.with_children(self.active_searchable_item.as_ref().and_then(
|searchable_item| {
let matches = self let matches = self
.searchable_items_with_matches .searchable_items_with_matches
.get(&searchable_item.downgrade())?; .get(&searchable_item.downgrade())?;
@ -207,8 +200,20 @@ impl View for BufferSearchBar {
.with_style(theme.search.match_index.container) .with_style(theme.search.match_index.container)
.aligned(), .aligned(),
) )
}, });
)) Flex::row()
.with_child(
Flex::column()
.with_child(
Flex::row()
.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))
.aligned(),
)
.with_children(match_count)
.aligned() .aligned()
.left() .left()
.top() .top()
@ -765,6 +770,7 @@ impl BufferSearchBar {
self.active_match_index.take(); self.active_match_index.take();
active_searchable_item.clear_matches(cx); active_searchable_item.clear_matches(cx);
let _ = done_tx.send(()); let _ = done_tx.send(());
cx.notify();
} else { } else {
let query = if self.current_mode == SearchMode::Regex { let query = if self.current_mode == SearchMode::Regex {
match SearchQuery::regex( match SearchQuery::regex(