Fix incorrect width estimation of ascii control characters
This commit is contained in:
parent
d28ce90ec7
commit
712c1537ad
2 changed files with 6 additions and 3 deletions
|
|
@ -13,6 +13,9 @@ Procedure when bumping the version number:
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Rendering glitches in unicode-based with estimation
|
||||||
|
|
||||||
## v0.3.2 - 2025-02-23
|
## v0.3.2 - 2025-02-23
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,10 @@ impl WidthDb {
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap_or(u8::MAX),
|
.unwrap_or(u8::MAX),
|
||||||
|
|
||||||
// The unicode width crate considers newlines to have a width of 1
|
// The unicode width crate considers control chars to have a width
|
||||||
// while the rendering code expects it to have a width of 0.
|
// of 1 even though they usually have a width of 0 when displayed.
|
||||||
WidthEstimationMethod::Unicode => grapheme
|
WidthEstimationMethod::Unicode => grapheme
|
||||||
.split('\n')
|
.split(|c: char| c.is_ascii_control())
|
||||||
.map(|s| s.width())
|
.map(|s| s.width())
|
||||||
.sum::<usize>()
|
.sum::<usize>()
|
||||||
.try_into()
|
.try_into()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue