diff --git a/docs/changelog.md b/docs/changelog.md index 118b03803..1f2a74649 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -87,6 +87,9 @@ As features stabilize some brief notes about them will accumulate here. * Multiple active multiplexer client domain connections could result in showing duplicate tabs in a window [#2616](https://github.com/wez/wezterm/issues/2616) +* Incorrect line width when applying hyperlink rules to a wrapped line + containing double-wide cells. + [#2568](https://github.com/wez/wezterm/issues/2568) #### Changed * Removed Last Resort fallback font diff --git a/termwiz/src/surface/line/line.rs b/termwiz/src/surface/line/line.rs index 64c03bb1d..53a530edf 100644 --- a/termwiz/src/surface/line/line.rs +++ b/termwiz/src/surface/line/line.rs @@ -1097,6 +1097,9 @@ impl Line { CellStorage::V(cells) => { for cell in other.visible_cells() { cells.push(cell.as_cell()); + for _ in 1.. cell.width() { + cells.push(Cell::new(' ', cell.attrs().clone())); + } } } CellStorage::C(cl) => { diff --git a/termwiz/src/surface/line/test.rs b/termwiz/src/surface/line/test.rs index 8db036b47..fd0da5fe9 100644 --- a/termwiz/src/surface/line/test.rs +++ b/termwiz/src/surface/line/test.rs @@ -8,6 +8,21 @@ use crate::surface::SEQ_ZERO; use k9::assert_equal as assert_eq; use std::sync::Arc; +/// There are 4 double-wide graphemes that occupy 2 cells each. +/// When we join the lines, we must preserve the invisible blank +/// that is part of the grapheme otherwise our metrics will be +/// wrong. +/// +#[test] +fn append_line() { + let mut line1: Line = "0123456789".into(); + let line2: Line = "グループaa".into(); + + line1.append_line(line2, SEQ_ZERO); + + assert_eq!(line1.len(), 20); +} + #[test] fn hyperlinks() { let text = "❤ 😍🤢 http://example.com \u{1f468}\u{1f3fe}\u{200d}\u{1f9b0} http://example.com";