Skip to content

Commit

Permalink
print: continue on 0 width graphemes or words
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rockorager committed Mar 12, 2024
1 parent c589139 commit 5e940fd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Window.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5e940fd

Please sign in to comment.