diff --git a/wezterm-gui/src/tabbar.rs b/wezterm-gui/src/tabbar.rs index b7bd0dfc7..1e6c0a208 100644 --- a/wezterm-gui/src/tabbar.rs +++ b/wezterm-gui/src/tabbar.rs @@ -116,7 +116,11 @@ fn compute_tab_title( Some(title) => title, None => { let title = if let Some(pane) = &tab.active_pane { - let mut title = pane.title.clone(); + let mut title = if tab.tab_title.is_empty() { + pane.title.clone() + } else { + tab.tab_title.clone() + }; let classic_spacing = if config.use_fancy_tab_bar { "" } else { " " }; if config.show_tab_index_in_tab_bar { title = format!( @@ -128,7 +132,7 @@ fn compute_tab_title( } else { 1 }, - pane.title, + title, classic_spacing, ); } diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs index 61d6721b1..dea3d2956 100644 --- a/wezterm-gui/src/termwindow/mod.rs +++ b/wezterm-gui/src/termwindow/mod.rs @@ -205,6 +205,7 @@ pub struct TabInformation { pub is_active: bool, pub active_pane: Option, pub window_id: MuxWindowId, + pub tab_title: String, } impl UserData for TabInformation { @@ -232,13 +233,7 @@ impl UserData for TabInformation { Ok(panes) }); fields.add_field_method_get("window_id", |_, this| Ok(this.window_id)); - fields.add_field_method_get("tab_title", |_, this| { - let mux = Mux::get(); - let tab = mux - .get_tab(this.tab_id) - .ok_or_else(|| mlua::Error::external(format!("tab {} not found", this.tab_id)))?; - Ok(tab.get_title()) - }); + fields.add_field_method_get("tab_title", |_, this| Ok(this.tab_title.clone())); fields.add_field_method_get("window_title", |_, this| { let mux = Mux::get(); let window = mux.get_window(this.window_id).ok_or_else(|| { @@ -3169,6 +3164,7 @@ impl TermWindow { tab_id: tab.tab_id(), is_active: tab_index == idx, window_id: self.mux_window_id, + tab_title: tab.get_title(), active_pane: panes .iter() .find(|p| p.is_active) @@ -3178,14 +3174,14 @@ impl TermWindow { .collect() } - fn get_pane_information(&mut self) -> Vec { + fn get_pane_information(&self) -> Vec { self.get_panes_to_render() .iter() .map(Self::pos_pane_to_pane_info) .collect() } - fn get_pos_panes_for_tab(&mut self, tab: &Arc) -> Vec { + fn get_pos_panes_for_tab(&self, tab: &Arc) -> Vec { let tab_id = tab.tab_id(); if let Some(pane) = self @@ -3218,7 +3214,7 @@ impl TermWindow { } } - fn get_panes_to_render(&mut self) -> Vec { + fn get_panes_to_render(&self) -> Vec { let mux = Mux::get(); let tab = match mux.get_active_tab_for_window(self.mux_window_id) { Some(tab) => tab,