Merge pull request #543 from zed-industries/fix-closing-items

Ensure `active_item_index` doesn't go off the end when closing items
This commit is contained in:
Antonio Scandurra 2022-03-05 15:03:05 +01:00 committed by GitHub
commit 34bbc05cec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -406,11 +406,13 @@ impl Pane {
});
if self.item_views.is_empty() {
self.update_active_toolbar(cx);
cx.emit(Event::Remove);
} else {
self.activate_item(new_active_item_index, cx);
self.active_item_index = cmp::min(new_active_item_index, self.item_views.len() - 1);
self.focus_active_item(cx);
self.activate(cx);
}
self.update_active_toolbar(cx);
cx.notify();
}