Severity: MEDIUM Status: Fixed
With variation-selector-always-wide on, an app that emits a base character
already carrying two combining marks followed by U+FE0F (e.g.
e + U+0301 + U+0327 + U+FE0F) produces:
renderContent lookahead
(cw == 1 and next_cell.is_padding → cw = 2) bumps cur_cx by 2 for a
cell that has no VS16 comb char. Because has_vs16 is false,
anchored is not reset, so the next changed cell whose grid column
matches the drifted cur_cx is written without an explicit moveTo —
the host terminal (which drew the base as 1 cell) then places it one
column to the left: one-column drift and ghost characters for the rest
of the run of changed cells on that line.Confirmed with a repro test: after 'e' + U+0301 + U+0327 (comb1=2,
comb2=40) and writeChar(0xFE0F), the cell comb slots were unchanged,
is_padding(next) == true, and cursor.x == 2.
Both combining-character paths in Screen.writeChar append the combining
index to the base cell and then unconditionally run the promotion block:
if (prev_cell.comb1 == 0) {
prev_cell.comb1 = cidx;
} else if (prev_cell.comb2 == 0) {
prev_cell.comb2 = cidx;
} // <- VS16 dropped when both slots are full; no tracking of success
...
if (char == 0xFE0F and !was_padding and char_width.getVariationSelectorAlwaysWide()) {
// promotion runs regardless of whether the append happened
The promotion only checks char == 0xFE0F, never whether the VS16 was
actually stored. The render-side lookahead compounded the inconsistency:
it infers “promoted pair” purely from width-1 base + following padding,
without verifying the base carries a VS16 comb char — the same inference
that misfires for any stale width-1+padding pair (e.g. after a
codepoint-widths override narrows a wide char to 1 while old cells with
their padding are still on screen).
stored), and the promotion
block additionally requires stored. When the VS16 cannot be stored the
behaviour falls back to the option-off semantics: the base stays width 1
with its two existing combining marks and no padding cell is created.renderContent now
computes has_vs16 from the cell’s comb chars before the width bump
and only applies the cw = 2 bump when the cell actually carries
U+FE0F. Non-VS16 width-1+padding pairs no longer advance cur_cx by 2;
the pre-existing skip-then-compare re-anchoring (cur_cx != x → moveTo)
self-corrects instead.src/screen.zig:
"variation-selector-always-wide does not promote when VS16 cannot be stored (bug #445)":
comb-full base + VS16 leaves no padding cell and the cursor at 1."render lookahead does not bump width for width-1 + padding without VS16 (bug #445)":
verifies a stale padding cell after a plain width-1 cell does not
suppress the explicit cursor reposition for the next cell.