szn

Bug 524 — NEL does not reset the column

524. 0x85 maps to IND instead of CR + LF

Severity: MEDIUM Status: ✅ FIXED Files: src/input.zig:207-208

Problem

// src/input.zig:207-208
0x84 => try self.screen.index(), // IND
0x85 => try self.screen.index(), // NEL (same down-move here)

The inline comment acknowledges the shortcut. ECMA-48 defines NEL (Next Line) as CR + LF — carriage return and line feed — so it must place the cursor at column 0 of the following line. Screen.index() is IND: it moves down while preserving the column.

Any application that terminates lines with 8-bit NEL rather than \r\n will stair-step diagonally across the screen instead of returning to the left margin. Bug #388 fixed the C1 dispatch so NEL is no longer swallowed by the C1 misroute, but kept this behaviour.

Proposed Fix

0x85 => {
    self.screen.cursor.x = 0;
    try self.screen.index();
},

and mirror the change for the 7-bit ESC E form if it is present. Add a test asserting that NEL from column N lands at column 0 of the next row.

Fix

// src/input.zig
0x85 => {
    // bug #524: NEL is CR + LF, so it returns to column 0 before moving down.
    self.screen.cursor.x = 0;
    try self.screen.index();
},

IND (0x84) is untouched — it correctly preserves the column.

Regression test

NEL (0x85) resets the column before moving down — bug #524 (src/input.zig) feeds "abc" then NEL and asserts the cursor lands at column 0 of row 1, then feeds "xy" + IND and asserts the column is preserved — pinning both handlers so a future edit cannot merge them again.

Verified with the full suite on Zig 0.16.0 and 0.17.0: 1049/1049 passing on both.

Bug #368 (LF/IND inside a scroll region bypassing region scrolling) and bug #388 (8-bit C1 misroutes) are the adjacent parser-fidelity defects.