diff --git a/wezterm-gui/src/termwindow/box_model.rs b/wezterm-gui/src/termwindow/box_model.rs index 97aa98da2..d903facc8 100644 --- a/wezterm-gui/src/termwindow/box_model.rs +++ b/wezterm-gui/src/termwindow/box_model.rs @@ -267,9 +267,25 @@ impl Element { } pub fn with_line(font: &Rc, line: &Line, palette: &ColorPalette) -> Self { - let mut content = vec![]; + let mut content: Vec = vec![]; + let mut prior_attr = None; for cluster in line.cluster(None) { + // Clustering may introduce cluster boundaries when the text hasn't actually + // changed style. Undo that here. + // There's still an issue where the style does actually change and we + // subsequently don't clip the element. + // + if let Some(prior) = content.last_mut() { + let (fg, bg) = prior_attr.as_ref().unwrap(); + if cluster.attrs.background() == *bg && cluster.attrs.foreground() == *fg { + if let ElementContent::Text(t) = &mut prior.content { + t.push_str(&cluster.text); + continue; + } + } + } + let child = Element::new(font, ElementContent::Text(cluster.text)).colors(ElementColors { border: BorderColor::default(), @@ -292,6 +308,7 @@ impl Element { }); content.push(child); + prior_attr.replace((cluster.attrs.foreground(), cluster.attrs.background())); } Self::new(font, ElementContent::Children(content))