szn

Bug 49 — Line-wrapping fires grid.scrollUp() instead of scrollUpInRegion() — breaks DECSTBM scroll regions

49. Line-wrapping fires grid.scrollUp() instead of scrollUpInRegion() — breaks DECSTBM scroll regions

File: src/screen.zig:153–162 Severity: CRITICAL Status: ✅ FIXED

if (self.mode.line_wrap) {
    self.cursor.x += 1;
    if (self.cursor.x >= self.grid.width) {
        self.cursor.x = 0;
        if (self.scroll_region) |r| {
            if (self.cursor.y == r[1]) {
                try self.scrollUpInRegion();
            } else {
                self.cursor.y += 1;
            }
        } else {
            if (self.cursor.y + 1 >= self.grid.height) {
                try self.grid.scrollUp();
            } else {
                self.cursor.y += 1;
            }
        }
    }
} else {
    self.cursor.x = @min(self.cursor.x + 1, self.grid.width - 1);
}

When a pane has DECSTBM set (e.g. \e[2;4r), text that autowraps at the region bottom pushes the entire grid up instead of scrolling only within regions 2–4. The region outside 2–4 gets corrupted. The fix makes autowrap respect the scroll region, matching the behavior used for explicit \n handling.