diff --git a/docs/changelog.md b/docs/changelog.md index 71e676780..f224e289d 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -42,6 +42,7 @@ As features stabilize some brief notes about them will accumulate here. * Improved: we now draw sextant glyphs from the Unicode Symbols for Legacy Computing block (1FB00) when `custom_block_glyphs` is enabled. * Changed: `COLORTERM=truecolor` is now set in the environment. [#875](https://github.com/wez/wezterm/issues/875) * New: `wezterm cli spawn --new-window` flag for creating a new window via the CLI [#887](https://github.com/wez/wezterm/issues/887) +* Fixed: closing last pane in a tab via `CloseCurrentPane` could cause the window to close [#890](https://github.com/wez/wezterm/issues/890) ### 20210502-154244-3f7122cb diff --git a/mux/src/lib.rs b/mux/src/lib.rs index 78c5dbe93..e3a7067e3 100644 --- a/mux/src/lib.rs +++ b/mux/src/lib.rs @@ -396,6 +396,12 @@ impl Mux { let tab = self.tabs.borrow_mut().remove(&tab_id)?; + if let Ok(mut windows) = self.windows.try_borrow_mut() { + for w in windows.values_mut() { + w.remove_by_id(tab_id); + } + } + let mut pane_ids = vec![]; for pos in tab.iter_panes() { pane_ids.push(pos.pane.pane_id()); diff --git a/mux/src/window.rs b/mux/src/window.rs index 22ed16383..06f444d1d 100644 --- a/mux/src/window.rs +++ b/mux/src/window.rs @@ -120,15 +120,12 @@ impl Window { tab } - pub fn remove_by_id(&mut self, id: TabId) -> bool { + pub fn remove_by_id(&mut self, id: TabId) { + let active = self.get_active().map(Rc::clone); if let Some(idx) = self.idx_by_id(id) { - let active = self.get_active().map(Rc::clone); self.tabs.remove(idx); - self.fixup_active_tab_after_removal(active); - true - } else { - false } + self.fixup_active_tab_after_removal(active); } pub fn get_active(&self) -> Option<&Rc> { diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs index dd255eabf..a62d64f1a 100644 --- a/wezterm-gui/src/termwindow/mod.rs +++ b/wezterm-gui/src/termwindow/mod.rs @@ -1058,6 +1058,7 @@ impl TermWindow { let panes = self.get_panes_to_render(); if panes.is_empty() { + log::warn!("maintain_blink: get_panes_to_render.is_empty() -> close window"); self.window.as_ref().unwrap().close(); return (false, None); } @@ -1915,7 +1916,7 @@ impl TermWindow { self.assign_overlay_for_pane(pane_id, overlay); promise::spawn::spawn(future).detach(); } else { - tab.kill_pane(pane_id); + mux.remove_pane(pane_id); } }