Fix control character width measurement

This commit is contained in:
Joscha 2024-04-25 19:45:35 +02:00
parent 94052c5a65
commit 8556fd8176
2 changed files with 12 additions and 0 deletions

View file

@ -13,6 +13,9 @@ Procedure when bumping the version number:
## Unreleased
### Fixed
- Width measurements of ASCII control characters
## v0.2.2 - 2024-01-14
### Fixed

View file

@ -101,6 +101,15 @@ impl WidthDb {
return Ok(());
}
for grapheme in self.requested.drain() {
if grapheme.chars().any(|c|c.is_ascii_control()){
// ASCII control characters like the escape character or the
// bell character tend to be interpreted specially by terminals.
// This may break width measurements. To avoid this, we just
// assign each control character a with of 0.
self.known.insert(grapheme, 0);
continue;
}
out.queue(Clear(ClearType::All))?
.queue(MoveTo(0, 0))?
.queue(Print(&grapheme))?;