From 5e940fd295cebdbffa9155e52be124d41bf89aff Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Mon, 11 Mar 2024 19:01:43 -0500 Subject: [PATCH] print: continue on 0 width graphemes or words Don't print 0 width graphemes or words. Usually these will be overwritten since we advance by 0 columns, however if one is at the end of text it can mess up rendering. Signed-off-by: Tim Culverhouse --- src/Window.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Window.zig b/src/Window.zig index 3a71654..2503c54 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -146,6 +146,7 @@ pub fn print(self: Window, segments: []Segment, opts: PrintOptions) !bool { continue; } const w = self.gwidth(s); + if (w == 0) continue; self.writeCell(col, row, .{ .char = .{ .grapheme = s, @@ -174,6 +175,7 @@ pub fn print(self: Window, segments: []Segment, opts: PrintOptions) !bool { // break lines when we can't fit this word, and the word isn't longer // than our width const word_width = self.gwidth(word.bytes); + if (word_width == 0) continue; if (word_width + col > self.width and word_width < self.width) { row += 1; col = 0; @@ -214,6 +216,7 @@ pub fn print(self: Window, segments: []Segment, opts: PrintOptions) !bool { const s = grapheme.slice(segment.text); if (std.mem.eql(u8, s, "\n")) return true; const w = self.gwidth(s); + if (w == 0) continue; self.writeCell(col, row, .{ .char = .{ .grapheme = s,