szn

Bug 369 — Stale wrapped flag on region-cleared lines

369. Same visual state, different continuation metadata depending on erase opcode

File: src/screen.zig:925-932 (EL 2 — correct), src/screen.zig:1016-1028 (ECH — missing) Severity: HIGH Status: ✅ FIXED

Fix (applied)

On inspection the codebase was mostly correct already — EL 0/1/2, ED 0/1/2 and insertLines all clear wrapped on blanked lines. The single gap was full-line ECH (eraseChars covering the whole row): it now clears the flag, matching EL 2 policy. Partial ECH keeps the continuation flag, as in xterm.

Test: full-line ECH clears wrapped flag, partial ECH keeps it — bug #369.

Problem

EL 2 memsets the line and sets line.wrapped = false. ECH can blank the entire line (@min(cx + n, width) == width) yet never touches wrapped; region-wide erase variants behave similarly. The grid then holds blank lines flagged as wrap-continuations; the next pane resize rewraps them as if glued to the preceding paragraph, scrambling layout.

Fix (proposed)

Centralise “line becomes blank” handling in one helper that always clears wrapped; call it from EL/ECH/ED/region clears. Test: fill two wrapped lines, ECH-clear the second entirely, resize narrower, assert the paragraph does not merge.