diff --git a/config/src/config.rs b/config/src/config.rs index 5b099edc7ad..84bfa38e78d 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -479,6 +479,13 @@ pub struct Config { #[dynamic(default = "default_tab_max_width")] pub tab_max_width: usize, + /// Specifies the minimum width that a tab can have + /// in the tab bar. Defaults to 5 glyphs in width. + /// If the tab title is shorter than this, the tab will + /// be sized to fit the title. + #[dynamic(default = "default_tab_min_width")] + pub tab_min_width: usize, + /// If true, hide the tab bar if the window only has a single tab. #[dynamic(default)] pub hide_tab_bar_if_only_one_tab: bool, @@ -1790,6 +1797,10 @@ fn default_tab_max_width() -> usize { 16 } +fn default_tab_min_width() -> usize { + 5 +} + fn default_update_interval() -> u64 { 86400 } diff --git a/docs/config/lua/config/tab_min_width.md b/docs/config/lua/config/tab_min_width.md new file mode 100644 index 00000000000..cb436a440a4 --- /dev/null +++ b/docs/config/lua/config/tab_min_width.md @@ -0,0 +1,14 @@ +--- +tags: + - tab_bar +--- +# `tab_min_width` + +Specifies the minimum width that a tab can have in the +tab bar when using either the of the tab modes. + +Defaults to 5 glyphs in width. + +```lua +config.tab_min_width = 5 +``` diff --git a/wezterm-gui/src/tabbar.rs b/wezterm-gui/src/tabbar.rs index 5e007f54a42..a014ca318cf 100644 --- a/wezterm-gui/src/tabbar.rs +++ b/wezterm-gui/src/tabbar.rs @@ -110,6 +110,7 @@ fn compute_tab_title( config: &ConfigHandle, hover: bool, tab_max_width: usize, + tab_min_width: usize ) -> TitleText { let title = call_format_tab_title(tab, tab_info, pane_info, config, hover, tab_max_width); @@ -141,10 +142,8 @@ fn compute_tab_title( // easier to click on tab titles, but we'll still go below // this if there are too many tabs to fit the window at // this width. - if !config.use_fancy_tab_bar { - while unicode_column_width(&title, None) < 5 { - title.push(' '); - } + while unicode_column_width(&title, None) < tab_min_width { + title.push(' '); } title } else { @@ -338,6 +337,7 @@ impl TabBarState { config, false, config.tab_max_width, + config.tab_min_width, ) }) .collect() @@ -413,6 +413,7 @@ impl TabBarState { config, hover, tab_title_len, + config.tab_min_width, ); let cell_attrs = if active {