Do not display match count when query is empty
This commit is contained in:
parent
b282bdfe5a
commit
a583d1c6cc
1 changed files with 25 additions and 19 deletions
|
@ -178,6 +178,29 @@ impl View for BufferSearchBar {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
let match_count = self
|
||||||
|
.active_searchable_item
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|searchable_item| {
|
||||||
|
if self.query(cx).is_empty() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let matches = self
|
||||||
|
.searchable_items_with_matches
|
||||||
|
.get(&searchable_item.downgrade())?;
|
||||||
|
let message = if let Some(match_ix) = self.active_match_index {
|
||||||
|
format!("{}/{}", match_ix + 1, matches.len())
|
||||||
|
} else {
|
||||||
|
"No matches".to_string()
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(
|
||||||
|
Label::new(message, theme.search.match_index.text.clone())
|
||||||
|
.contained()
|
||||||
|
.with_style(theme.search.match_index.container)
|
||||||
|
.aligned(),
|
||||||
|
)
|
||||||
|
});
|
||||||
Flex::row()
|
Flex::row()
|
||||||
.with_child(
|
.with_child(
|
||||||
Flex::column()
|
Flex::column()
|
||||||
|
@ -190,25 +213,7 @@ impl View for BufferSearchBar {
|
||||||
.with_child(self.render_nav_button(">", Direction::Next, cx))
|
.with_child(self.render_nav_button(">", Direction::Next, cx))
|
||||||
.aligned(),
|
.aligned(),
|
||||||
)
|
)
|
||||||
.with_children(self.active_searchable_item.as_ref().and_then(
|
.with_children(match_count)
|
||||||
|searchable_item| {
|
|
||||||
let matches = self
|
|
||||||
.searchable_items_with_matches
|
|
||||||
.get(&searchable_item.downgrade())?;
|
|
||||||
let message = if let Some(match_ix) = self.active_match_index {
|
|
||||||
format!("{}/{}", match_ix + 1, matches.len())
|
|
||||||
} else {
|
|
||||||
"No matches".to_string()
|
|
||||||
};
|
|
||||||
|
|
||||||
Some(
|
|
||||||
Label::new(message, theme.search.match_index.text.clone())
|
|
||||||
.contained()
|
|
||||||
.with_style(theme.search.match_index.container)
|
|
||||||
.aligned(),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
))
|
|
||||||
.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(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue