diff --git a/CHANGELOG.md b/CHANGELOG.md index 0305201..b70bde6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ Procedure when bumping the version number: ## Unreleased +### Fixed +- Rendering glitches in unicode-based with estimation + ## v0.3.2 - 2025-02-23 ### Added diff --git a/src/widthdb.rs b/src/widthdb.rs index bb21ef6..fe5a26e 100644 --- a/src/widthdb.rs +++ b/src/widthdb.rs @@ -88,10 +88,10 @@ impl WidthDb { .try_into() .unwrap_or(u8::MAX), - // The unicode width crate considers newlines to have a width of 1 - // while the rendering code expects it to have a width of 0. + // The unicode width crate considers control chars to have a width + // of 1 even though they usually have a width of 0 when displayed. WidthEstimationMethod::Unicode => grapheme - .split('\n') + .split(|c: char| c.is_ascii_control()) .map(|s| s.width()) .sum::() .try_into()