File: src/screen.zig (LF/IND handling), src/grid.zig (scrollUp)
Severity: HIGH
Status: ✅ FIXED
Screen.index() now short-circuits whenever a scroll region is active:
scrollUpInRegion() (unchanged);grid.scrollUp() that pushed
out-of-region lines into scrollback;Tests: LF below scroll region clamps without whole-grid scroll — bug
#368 (row content survives, no history push, downward move below region);
LF at region bottom scrolls only the region — bug #368.
When DECSTBM margins are active and the cursor sits below/at the bottom of the region but above the screen bottom, line-feed/index must scroll only within the region. The audit sweep identified paths where LF/IND bypass the region check and drive whole-grid scrolling — lines from outside the region get pushed into scrollback and region content desyncs. User-visible daily in apps that use scroll regions (editors, htop).
Route every cursor-advance-newline through one helper that honours
origin_mode + region; add table-driven tests for LF at each boundary
combination (inside/below region × origin on/off).