Skip to content

Commit 7ebeb93

Browse files
committed
fix: collapse orphaned wide-char lead on trailing-column overlay
When a narrow glyph is floated onto the trailing column of an already-placed wide char, the present loops skipped the trailing column and the overlay was dropped (the wide char painted over both cells). Detect the partial overwrite (non-space trailing cell) and collapse the orphaned lead to a space at width 1 so the overlay glyph emits. Applied symmetrically to present_cups and present_lines; rows without overlapping writes stay byte-for-byte identical. Fixes #75
1 parent 352cb27 commit 7ebeb93

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

src/clayterm.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,21 @@ static void present_cups(struct Clayterm *ct, int row) {
176176
if (w < 1)
177177
w = 1;
178178

179+
/* If a narrow glyph was floated onto a trailing column of this wide
180+
* char, render_text left the lead cell but the trailing cell now
181+
* holds a non-space glyph. Collapse the orphaned lead to a space and
182+
* treat it as width-1 so the overlay glyph emits on the next pass. */
183+
if (w > 1) {
184+
for (int i = 1; i < w && x + i < ct->w; i++) {
185+
Cell *bw = cell_at(ct, ct->back, x + i, y);
186+
if (bw->ch != ' ') {
187+
back->ch = ' ';
188+
w = 1;
189+
break;
190+
}
191+
}
192+
}
193+
179194
if (cell_cmp(back, front)) {
180195
/* copy to front */
181196
*front = *back;
@@ -222,6 +237,21 @@ static void present_lines(struct Clayterm *ct) {
222237
if (w < 1)
223238
w = 1;
224239

240+
/* If a narrow glyph was floated onto a trailing column of this wide
241+
* char, render_text left the lead cell but the trailing cell now
242+
* holds a non-space glyph. Collapse the orphaned lead to a space and
243+
* treat it as width-1 so the overlay glyph emits on the next pass. */
244+
if (w > 1) {
245+
for (int i = 1; i < w && x + i < ct->w; i++) {
246+
Cell *bw = cell_at(ct, ct->back, x + i, y);
247+
if (bw->ch != ' ') {
248+
back->ch = ' ';
249+
w = 1;
250+
break;
251+
}
252+
}
253+
}
254+
225255
*front = *back;
226256

227257
emit_attr(ct, back->fg, back->bg);

0 commit comments

Comments
 (0)