szn

Bug 463 — Screen TAB handling underflows on zero width and can divide by zero

463. TAB clamp wraps; tab_stop unchecked

Severity: MEDIUM Status: ✅ FIXED Files: src/screen.zig


Root Cause Analysis

In src/screen.zig:700-704:

self.cursor.x = ((self.cursor.x / self.tab_stop) + 1) * self.tab_stop;
if (self.cursor.x >= self.grid.width) self.cursor.x = self.grid.width - 1;

width==0 → 0-1 wraps. tab_stop: u32 = 8 is a plain mutable field; if ever set to 0, cursor.x / 0 traps. Sibling BS handler at :718 already uses -|.

Proposed Fix

Guard tab_stop == 0 (treat as no-op or 8) and use width -| 1 with an early width==0 return.