branch_list: Ensure index is within list bounds. (#2724)

Z-2630


Release Notes:
- Fixed a crash in branch list that occurred when confirming a match in
empty list.
This commit is contained in:
Piotr Osiewicz 2023-07-14 19:11:24 +02:00 committed by GitHub
commit c466711cd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -182,7 +182,9 @@ impl PickerDelegate for BranchListDelegate {
fn confirm(&mut self, cx: &mut ViewContext<Picker<Self>>) {
let current_pick = self.selected_index();
let current_pick = self.matches[current_pick].string.clone();
let Some(current_pick) = self.matches.get(current_pick).map(|pick| pick.string.clone()) else {
return;
};
cx.spawn(|picker, mut cx| async move {
picker
.update(&mut cx, |this, cx| {