branch_list: Show match count on the right hand side of a header.

Co-authored-by: Antonio <antonio@zed.dev>
This commit is contained in:
Piotr Osiewicz 2023-07-05 16:56:08 +02:00
parent 85add260f6
commit ec47464bba

View file

@ -221,17 +221,14 @@ impl PickerDelegate for BranchListDelegate {
.with_style(style.container)
} else {
Flex::row()
.with_child(Label::new("Branches", style.label.clone()).aligned().left())
.with_child(Label::new("Branches", style.label.clone()))
.with_children(self.matches.is_empty().not().then(|| {
let suffix = if self.matches.len() == 1 { "" } else { "es" };
Flex::row()
.align_children_center()
.with_child(Label::new(
format!("{} match{}", self.matches.len(), suffix),
style.label,
))
.aligned()
.right()
Label::new(
format!("{} match{}", self.matches.len(), suffix),
style.label,
)
.flex_float()
}))
.contained()
.with_style(style.container)