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

Antonio Scandurra created

Ensure `active_item_index` doesn't go off the end when closing items

Change summary

crates/workspace/src/pane.rs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

Detailed changes

crates/workspace/src/pane.rs 🔗

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