From b07babb335219a4cc35e6f40d4e06b6a982c1a89 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 6 Jan 2020 00:03:01 -0800 Subject: [PATCH] Closing a window closes the window, rather than the tab refs: https://github.com/wez/wezterm/issues/101 --- src/frontend/gui/termwindow.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/frontend/gui/termwindow.rs b/src/frontend/gui/termwindow.rs index 2e448c14f..7613ad581 100644 --- a/src/frontend/gui/termwindow.rs +++ b/src/frontend/gui/termwindow.rs @@ -197,19 +197,16 @@ impl WindowCallbacks for TermWindow { } fn can_close(&mut self) -> bool { - // can_close triggers the current tab to be closed. - // If we have no tabs left then we can close the whole window. - // If we're in a weird state, then we allow the window to close too. let mux = Mux::get().unwrap(); - let tab = match mux.get_active_tab_for_window(self.mux_window_id) { - Some(tab) => tab, - None => return true, - }; - mux.remove_tab(tab.tab_id()); - if let Some(mut win) = mux.get_window_mut(self.mux_window_id) { - win.remove_by_id(tab.tab_id()); - return win.is_empty(); + let tab_ids: Vec = if let Some(win) = mux.get_window(self.mux_window_id) { + win.iter().map(|tab| tab.tab_id()).collect() + } else { + return true; }; + + for id in tab_ids { + mux.remove_tab(id); + } true }