Prevent empty panes from being zoomed (#2520)

Antonio Scandurra created

Closes
https://linear.app/zed-industries/issue/Z-1789/empty-panes-should-not-be-zoomable

Change summary

crates/workspace/src/pane.rs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

Detailed changes

crates/workspace/src/pane.rs 🔗

@@ -683,7 +683,7 @@ impl Pane {
     pub fn toggle_zoom(&mut self, _: &ToggleZoom, cx: &mut ViewContext<Self>) {
         if self.zoomed {
             cx.emit(Event::ZoomOut);
-        } else {
+        } else if !self.items.is_empty() {
             cx.emit(Event::ZoomIn);
         }
     }
@@ -983,6 +983,10 @@ impl Pane {
                 .remove(&item.id());
         }
 
+        if self.items.is_empty() && self.zoomed {
+            cx.emit(Event::ZoomOut);
+        }
+
         cx.notify();
     }