Skip to content

Comments

fix: always clear new row cells during scroll to prevent stale data#134

Draft
darrinm wants to merge 2 commits intocoder:mainfrom
darrinm:fix/clear-stale-row-cells
Draft

fix: always clear new row cells during scroll to prevent stale data#134
darrinm wants to merge 2 commits intocoder:mainfrom
darrinm:fix/clear-stale-row-cells

Conversation

@darrinm
Copy link

@darrinm darrinm commented Feb 24, 2026

Summary

  • Make row clearing unconditional in cursorDownScroll() (Screen.zig patch)
  • Previously, new rows were only cleared when the cursor had a non-default background color (bg_color != .none)
  • With default cursor style (after ESC[0m reset), new rows created during scrolling retained stale cell data from previously used page memory

This caused periodic viewport corruption where content from old rows appeared horizontally merged into current rows. The bug was transient (self-correcting on the next write), periodic (~every 11 writes at cols=160), and affected all column widths at different frequencies.

Root cause

pages.grow() extends existing pages by appending rows, but the cell memory may contain data from previously erased rows. cursorDownScroll() was supposed to clear these cells, but the clearing was conditional on self.cursor.style.bg_color != .none. Programs that reset attributes with ESC[0m (which sets bg_color = .none) left stale cells visible on empty lines.

Test plan

  • bun test lib/viewport-row-merge.test.ts — 0 corrupt reps across all scrollback sizes
  • bun test lib/viewport-corruption.test.ts — viewport corruption regression tests pass
  • bun test — full suite passes

🤖 Generated with Claude Code

darrinm and others added 2 commits February 23, 2026 20:50
cursorDownScroll() only cleared new row cells when the cursor had a
non-default background color. With default cursor style (after ESC[0m
reset), new rows created during scrolling retained stale cell data from
previously used page memory, causing periodic viewport corruption where
content from old rows appeared horizontally merged into current rows.

Make row clearing unconditional so stale cells never become visible,
regardless of cursor style.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant