Only count existing branches in picker search (#22908)

Aaron Feickert and Marshall Bowers created

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>

Change summary

crates/vcs_menu/src/lib.rs | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

Detailed changes

crates/vcs_menu/src/lib.rs 🔗

@@ -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)
             });