Prevent empty panes from being zoomed

This commit is contained in:
Antonio Scandurra 2023-05-24 10:34:56 +02:00
parent e463e3b2e8
commit 168ff99927

View file

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