reflowCursorInternal trims trailing empty screen lines during copy-mode entry, shifting visible grid down and corrupting promptFile: src/grid.zig:754-764
Severity: HIGH
Status: ✅ FIXED
Running interactive applications (such as Antigravity CLI) inside szn, entering copy-mode, scrolling up, and then exiting copy-mode resulted in rendering glitches near the bottom of the screen where the input prompt was shifted down or layout corrupted.
enterCopyMode), pane.forceReflow() invokes reflowCursorInternal at the current window width (new_width == self.width). reflowCursorInternal calculated process_limit by trimming trailing empty rows from the bottom of self.lines (the visible screen). When scrollback history was present (hist_len > 0), dropping trailing empty screen rows reduced the total line count to $H + V - E$. During layout reconstruction, self.lines stole $E$ lines from self.history to fill the top of the visible screen, shifting all visible screen content down by $E$ rows.rewrap (src/grid.zig), when cursor_offset (co) was at or beyond the last character cell of a line (co >= cells.len), or on an empty prompt line, the cursor boundary condition (co == i and i == cells.len) failed for co > cells.len or co > 0 on empty lines. As a result, rewrap never set out_cursor_pos, causing new_cursor_logical_line to default to 0 (line $L-1$). When exiting copy-mode, the cursor was moved to $L-1$ instead of $L$, causing double-line ghosting.src/grid.zig, updated reflowCursorInternal so that when reflowing at the same width with history present (new_width == self.width and hist_len > 0), process_limit is set to total.src/grid.zig, updated rewrap so that empty lines (cells.len == 0) and trailing cursor offsets (co >= cells.len) correctly record out_cursor_pos clamped to new_width - 1, keeping the cursor on line $L$ at column cursor_x.