szn

Bug 370 — CUF/CUB/back-tab edge wrapping wrong

370. Horizontal motion crosses row boundaries where xterm clamps

File: src/screen.zig (CUF/CUB/CBT handlers) Severity: HIGH Status: ❌ FALSE POSITIVE (intentional design) Related: deferred-wrap representation is otherwise sound (cursor.x == width)

Resolution

On closer inspection this is deliberate, tested behaviour, not an accident:

While strict xterm/VT510 CUF/CUB clamps at margins, szn’s logical-line-aware horizontal movement supports modern TUIs navigating wrapped output. Changing it would break the documented design. Closing as intentional; revisit only if a concrete app incompatibility appears.

Problem

The audit sweep found CUF past the last column and CUB before column 0 can carry into adjacent rows instead of stopping at the margin, and back-tab skips tab stops across the left edge incorrectly. Applications that position the cursor with relative moves near edges (ncurses apps) render misaligned.

Fix (proposed)

Clamp CUF at the right margin (respecting the deferred-wrap x == width state) and CUB at column 0; make back-tab iterate stops within the row only. Add boundary tests mirroring the existing wrap tests.