Only count existing branches in picker search (#22908)
When displaying the number of matches in the branch picker during a search, don't count the "create new branch" option as a match, since it only appears when _no_ existing branches are found. <img width="530" alt="Screenshot 2025-01-09 at 12 17 30" src="https://github.com/user-attachments/assets/c4e6ac6f-d842-4b2f-a3af-ec28c9d90f0a" /> Closes #22905. Release Notes: - Fixed result count in branch picker searches. --------- Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
parent
9ea7ed8e0a
commit
8b4370f170
1 changed files with 9 additions and 2 deletions
|
@ -128,6 +128,13 @@ impl BranchListDelegate {
|
|||
branch_name_trailoff_after,
|
||||
})
|
||||
}
|
||||
|
||||
fn branch_count(&self) -> usize {
|
||||
self.matches
|
||||
.iter()
|
||||
.filter(|item| matches!(item, BranchEntry::Branch(_)))
|
||||
.count()
|
||||
}
|
||||
}
|
||||
|
||||
impl PickerDelegate for BranchListDelegate {
|
||||
|
@ -308,8 +315,8 @@ impl PickerDelegate for BranchListDelegate {
|
|||
.into_any_element()
|
||||
} else {
|
||||
let match_label = self.matches.is_empty().not().then(|| {
|
||||
let suffix = if self.matches.len() == 1 { "" } else { "es" };
|
||||
Label::new(format!("{} match{}", self.matches.len(), suffix))
|
||||
let suffix = if self.branch_count() == 1 { "" } else { "es" };
|
||||
Label::new(format!("{} match{}", self.branch_count(), suffix))
|
||||
.color(Color::Muted)
|
||||
.size(LabelSize::Small)
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue