1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-27 02:25:28 +03:00

fix: whole tab terminated when only zoomed pane exited

closes: https://github.com/wez/wezterm/issues/1235
This commit is contained in:
Wez Furlong 2021-10-17 08:34:35 -07:00
parent d461c1c0b6
commit e7fc5f0e9e
2 changed files with 36 additions and 16 deletions

View File

@ -59,6 +59,7 @@ As features stabilize some brief notes about them will accumulate here.
* Fixed: fonts with emoji presentation are shifted to better align with the primary font baseline [#1203](https://github.com/wez/wezterm/issues/1203) * Fixed: fonts with emoji presentation are shifted to better align with the primary font baseline [#1203](https://github.com/wez/wezterm/issues/1203)
* New: [window_padding](config/lua/config/window_padding.md) now accepts values such as `"1cell"` or `"30%"` to compute values based on font or window metrics. * New: [window_padding](config/lua/config/window_padding.md) now accepts values such as `"1cell"` or `"30%"` to compute values based on font or window metrics.
* New: BSDish systems now support [toast notifications](https://github.com/wez/wezterm/issues/489) * New: BSDish systems now support [toast notifications](https://github.com/wez/wezterm/issues/489)
* Fixed: the whole tab was closed when only the zoomed pane exited. [#1235](https://github.com/wez/wezterm/issues/1235)
### 20210814-124438-54e29167 ### 20210814-124438-54e29167

View File

@ -560,23 +560,35 @@ impl Tab {
/// Walks the pane tree to produce the topologically ordered flattened /// Walks the pane tree to produce the topologically ordered flattened
/// list of PositionedPane instances along with their positioning information. /// list of PositionedPane instances along with their positioning information.
pub fn iter_panes(&self) -> Vec<PositionedPane> { pub fn iter_panes(&self) -> Vec<PositionedPane> {
self.iter_panes_impl(true)
}
/// Like iter_panes, except that it will include all panes, regardless of
/// whether one of them is currently zoomed.
pub fn iter_panes_ignoring_zoom(&self) -> Vec<PositionedPane> {
self.iter_panes_impl(false)
}
fn iter_panes_impl(&self, respect_zoom_state: bool) -> Vec<PositionedPane> {
let mut panes = vec![]; let mut panes = vec![];
if let Some(zoomed) = self.zoomed.borrow().as_ref() { if respect_zoom_state {
let size = *self.size.borrow(); if let Some(zoomed) = self.zoomed.borrow().as_ref() {
panes.push(PositionedPane { let size = *self.size.borrow();
index: 0, panes.push(PositionedPane {
is_active: true, index: 0,
is_zoomed: true, is_active: true,
left: 0, is_zoomed: true,
top: 0, left: 0,
width: size.cols.into(), top: 0,
pixel_width: size.pixel_width.into(), width: size.cols.into(),
height: size.rows.into(), pixel_width: size.pixel_width.into(),
pixel_height: size.pixel_height.into(), height: size.rows.into(),
pane: Rc::clone(zoomed), pixel_height: size.pixel_height.into(),
}); pane: Rc::clone(zoomed),
return panes; });
return panes;
}
} }
let active_idx = *self.active.borrow(); let active_idx = *self.active.borrow();
@ -1119,6 +1131,7 @@ impl Tab {
F: Fn(usize, &Rc<dyn Pane>) -> bool, F: Fn(usize, &Rc<dyn Pane>) -> bool,
{ {
let mut dead_panes = vec![]; let mut dead_panes = vec![];
let zoomed_pane = self.zoomed.borrow().as_ref().map(|p| p.pane_id());
{ {
let root_size = *self.size.borrow(); let root_size = *self.size.borrow();
@ -1147,6 +1160,10 @@ impl Tab {
if pane_index == active_idx { if pane_index == active_idx {
active_idx = pane_index.saturating_sub(1); active_idx = pane_index.saturating_sub(1);
} }
if Some(pane.pane_id()) == zoomed_pane {
// If we removed the zoomed pane, un-zoom our state!
self.zoomed.borrow_mut().take();
}
let parent; let parent;
match cursor.unsplit_leaf() { match cursor.unsplit_leaf() {
Ok((c, dead, p)) => { Ok((c, dead, p)) => {
@ -1225,7 +1242,9 @@ impl Tab {
} }
pub fn is_dead(&self) -> bool { pub fn is_dead(&self) -> bool {
let panes = self.iter_panes(); // Make sure we account for all panes, so that we don't
// kill the whole tab if the zoomed pane is dead!
let panes = self.iter_panes_ignoring_zoom();
let mut dead_count = 0; let mut dead_count = 0;
for pos in &panes { for pos in &panes {
if pos.pane.is_dead() { if pos.pane.is_dead() {