szn

Bug 447 — Term.drawLine trailing clearToEOL lands on the second host cell of a line-ending VS16 emoji

447. clearToEOL erases the right half of a promoted emoji at line end

Severity: LOW Status: Fixed

Symptoms

On the client-side redraw path (Term.drawLine, used by full redraws), when the last content on a line is a promoted emoji pair (base + U+FE0F with variation-selector-always-wide on), the trailing clearToEOL was issued from end_col + 1 — the padding cell’s column. On terminals that render base+VS16 as one wide glyph occupying two cells (Kitty, and other hosts the option exists for), that erase starts inside the glyph: the right half of the emoji is blanked at every redraw.

The same geometry existed before the option landed (option-off base+VS16 cells produced the identical EL position), so this is a pre-existing defect surfaced by the feature analysis rather than a regression of the option commit itself.


Root Cause Analysis

drawLine skips padding cells when painting and finds the last non-padding content column (end_col). The erase start is computed as

const next_col = end_col + char_width.charWidth(s.grid.getCell(end_col, ly).char);

For a promoted base charWidth is 1, but in grid space the content extends through the padding cell at end_col + 1; one-past-the-last-drawn-column is therefore end_col + 2. The formula only accounted for charWidth-based wide pairs, not for promotion padding.


Solution

  1. After computing next_col, if the cell at next_col is a padding cell, advance next_col by one so the EL begins after the promoted pair. This matches the grid model (option on ⇒ the pair occupies two cells).
  2. With the option off, szn’s one-cell model intentionally mismatches widening hosts; enabling the option remains the documented remedy (see README “Variation Selector-16 (Emoji Presentation)” section).
  3. Regression test in src/tty/tty.zig: "drawLine clearToEOL skips the padding cell of a promoted VS16 pair (bug #447)": builds a line ending in a promoted pair followed by one empty column and asserts the cursor is positioned at pair_end + 2 (not on the padding column) before the erase.