szn

Bug 492 — region scrolls shift sixel anchors outside the region

492. shiftSixelAnchors is region-blind

Severity: MEDIUM (sixel overlay smear/drift after region scrolls) Status: 🟢 FIXED Files: src/screen.zig:637, src/screen.zig:656, src/screen.zig:1382, src/screen.zig:1429

Problem

scrollUpInRegion/scrollDownInRegion (and the region branches of scrollUp/scrollDown) move only the lines inside [top, bottom] — but then call shiftSixelAnchors(±n), which shifts every image registered on the screen, including ones anchored outside the region whose lines never moved. Any region scroll (DECSTBM — used by vim, tmux panes, progress bars, etc.) permanently desyncs those images’ anchors from their marker cells → the sixel overlay smears or drifts away from its text.

Proposed Fix

shiftSixelAnchors should take the [top, bottom] range and shift only images intersecting it (anchor row within range, or footprint overlapping range). Note SixelImage already carries alt_screen tagging for a similar filter (bug #219) — the same pattern applies.

Resolution

Updated shiftSixelAnchors to accept an optional region: ?[2]u32. When region is provided, only images whose footprint intersects [top, bottom] are shifted; images positioned entirely above or below the scroll region are left intact. Updated all call sites in scrollUpInRegion, scrollDownInRegion, scrollUp, scrollDown, advanceLine, resize, and placeSixelImage. Added regression test region scroll does not shift sixel anchors outside scroll region — bug #492.