terminal: handle width==3 glyphs by just pretending they're width 2

This commit is contained in:
Mitchell Hashimoto
2023-11-20 19:55:06 -08:00
parent d4e149a26b
commit 3c98c6375a

View File

@ -770,7 +770,14 @@ pub fn print(self: *Terminal, c: u21) !void {
// Determine the width of this character so we can handle // Determine the width of this character so we can handle
// non-single-width characters properly. // non-single-width characters properly.
const width: usize = @intCast(@max(0, ziglyph.display_width.codePointWidth(c, .half))); const width: usize = @intCast(@min(
@max(0, ziglyph.display_width.codePointWidth(c, .half)),
2,
));
// Note: it is possible to have a width of "3" and a width of "-1"
// from ziglyph. We should look into those cases and handle them
// appropriately.
assert(width <= 2); assert(width <= 2);
// log.debug("c={x} width={}", .{ c, width }); // log.debug("c={x} width={}", .{ c, width });