From b9aec2fcad5fbba7b33a79e5f464113066108ae1 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 9 Dec 2021 08:34:19 -0700 Subject: [PATCH] tabbar: fix double wide characters in tab titles refs: #1371 --- docs/changelog.md | 1 + wezterm-gui/src/tabbar.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index 3850cf69b..5c2947030 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -23,6 +23,7 @@ As features stabilize some brief notes about them will accumulate here. * DECSTR (terminal soft reset) now turns off DECLRMM (left and right margin mode). Thanks to [@ninjalj](https://github.com/ninjalj)! [#1376](https://github.com/wez/wezterm/pull/1376) * Improved conformance of CUP, HVP, SLRM, STBM escape sequences by support empty first parameter. Thanks to [@ninjalj](https://github.com/ninjalj)! [#1377](https://github.com/wez/wezterm/pull/1377) +* tab bar didn't correctly handle double-wide cells and could truncate at edges when using `format-tab-title` [#1371](https://github.com/wez/wezterm/issues/1371) ### 20211205-192649-672c1cc1 diff --git a/wezterm-gui/src/tabbar.rs b/wezterm-gui/src/tabbar.rs index 532400546..a28c9350f 100644 --- a/wezterm-gui/src/tabbar.rs +++ b/wezterm-gui/src/tabbar.rs @@ -382,7 +382,14 @@ fn parse_status_text(text: &str, default_cell: CellAttributes) -> Line { fn flush_print(buf: &mut String, cells: &mut Vec, pen: &CellAttributes) { for g in unicode_segmentation::UnicodeSegmentation::graphemes(buf.as_str(), true) { - cells.push(Cell::new_grapheme(g, pen.clone())); + let cell = Cell::new_grapheme(g, pen.clone()); + let width = cell.width(); + cells.push(cell); + for _ in 1..width { + // Line/Screen expect double wide graphemes to be followed by a blank in + // the next column position, otherwise we'll render incorrectly + cells.push(Cell::blank_with_attrs(pen.clone())); + } } buf.clear(); }