Avoid panic when closing the last tab in a pane, due to calling activate_item

This commit is contained in:
Max Brunsfeld 2022-01-27 15:38:10 -08:00
parent 3abd7bc8dd
commit 4f0ffdcdaf

View file

@ -312,7 +312,9 @@ impl Pane {
pub fn activate_item(&mut self, index: usize, cx: &mut ViewContext<Self>) {
if index < self.item_views.len() {
let prev_active_item_ix = mem::replace(&mut self.active_item_index, index);
if prev_active_item_ix != self.active_item_index {
if prev_active_item_ix != self.active_item_index
&& prev_active_item_ix < self.item_views.len()
{
self.item_views[prev_active_item_ix].1.deactivated(cx);
}
self.update_active_toolbar(cx);