szn

Bug 223 — Screen.resize uses main cursor position to compute alt grid cursor — alt cursor drifts

223. Screen.resize uses main cursor position to compute alt grid cursor — alt cursor drifts

File: src/screen.zig:329–338 Severity: MEDIUM Status: ✅ FIXED — changed alt grid resize to read from self.alt_cursor.x/y instead of self.cursor.x/y.

pub fn resize(self: *Screen, width: u32, height: u32) Error!void {
    var cx = self.cursor.x;
    var cy = self.cursor.y;
    try self.grid.setSizeCursor(width, height, self.cursor.x, self.cursor.y, &cx, &cy);
    if (self.alt_grid) |*g| {
        var alt_cx = self.cursor.x;   // ← uses MAIN cursor, not self.alt_cursor
        var alt_cy = self.cursor.y;   // ← uses MAIN cursor, not self.alt_cursor
        try g.setSizeCursor(width, height, self.cursor.x, self.cursor.y, &alt_cx, &alt_cy);
    }

When the alt screen is active (self.mode.alt_screen == true), self.cursor holds the alt screen’s cursor (swapped in useAltScreen). If the alt screen is not active but an alt_grid exists (e.g. the pane was resized while on the main screen), self.cursor is the main cursor, and the alt grid’s cursor is in self.alt_cursor. The resize code reads self.cursor.x/y unconditionally for the alt grid, so the alt grid’s cursor position is derived from the wrong source whenever the main screen is active during a resize.

Fix: Use self.alt_cursor.x/y as input to setSizeCursor for the alt grid, matching forceReflow which already uses self.cursor.x/y for both grids (correctly, since forceReflow is called when the pane is active and self.cursor reflects the active grid).