CloseCurrentPane on last pane in a tab results in window closing

The issue is that the pane was only removed from the tab when explicitly
closed, leaving it to be later detected and flushed.

However, in the meantime, when performing eg: cursor blink maintenance,
if the set of panes in the tab is empty then the window would close.

The resolution is to ask the mux (rather than the tab) to kill the pane,
so that the cascading closure of the tab causes the window's active
tab to reference the correct remaining tab.

refs: #890
This commit is contained in:
Wez Furlong committed 2021-06-19 11:06:14 -07:00
1 parent e3fdef7fb4
commit d57bc9b3dc
4 files changed
+12 -7

No files matched your search

+1
View File
@@ -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
+6
View File
@@ -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());
+3 -6
View File
@@ -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<Tab>> {
+2 -1
View File
@@ -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);
}
}