add switch_to_last_active_tab_when_closing_tab config option
refs: https://github.com/wez/wezterm/issues/2487
This commit is contained in:
1 parent
3583ccfc5e
commit
7d4b8249d7
2 files changed
+21
-4
No files matched your search
@@ -94,6 +94,9 @@ pub struct Config {
|
||||
/// The color palette
|
||||
pub colors: Option<Palette>,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub switch_to_last_active_tab_when_closing_tab: bool,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub window_frame: WindowFrameConfig,
|
||||
|
||||
|
||||
+18
-4
@@ -128,17 +128,31 @@ impl Window {
|
||||
pub fn remove_by_idx(&mut self, idx: usize) -> Rc<Tab> {
|
||||
self.invalidate();
|
||||
let active = self.get_active().map(Rc::clone);
|
||||
let tab = self.tabs.remove(idx);
|
||||
self.fixup_active_tab_after_removal(active);
|
||||
tab
|
||||
self.do_remove_idx(idx, active)
|
||||
}
|
||||
|
||||
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) {
|
||||
self.tabs.remove(idx);
|
||||
self.do_remove_idx(idx, active);
|
||||
}
|
||||
}
|
||||
|
||||
fn do_remove_idx(&mut self, idx: usize, active: Option<Rc<Tab>>) -> Rc<Tab> {
|
||||
if let (Some(active), Some(removing)) = (&active, self.tabs.get(idx)) {
|
||||
if active.tab_id() == removing.tab_id()
|
||||
&& config::configuration().switch_to_last_active_tab_when_closing_tab
|
||||
{
|
||||
// If we are removing the active tab, switch back to
|
||||
// the previously active tab
|
||||
if let Some(last_active) = self.get_last_active_idx() {
|
||||
self.set_active_without_saving(last_active);
|
||||
}
|
||||
}
|
||||
}
|
||||
let tab = self.tabs.remove(idx);
|
||||
self.fixup_active_tab_after_removal(active);
|
||||
tab
|
||||
}
|
||||
|
||||
pub fn get_active(&self) -> Option<&Rc<Tab>> {
|
||||
|
||||
Reference in new issue
Block a user