fix: always clear new row cells during scroll to prevent stale data#134
Draft
darrinm wants to merge 2 commits intocoder:mainfrom
Draft
fix: always clear new row cells during scroll to prevent stale data#134darrinm wants to merge 2 commits intocoder:mainfrom
darrinm wants to merge 2 commits intocoder:mainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cursorDownScroll()(Screen.zig patch)bg_color != .none)ESC[0mreset), new rows created during scrolling retained stale cell data from previously used page memoryThis 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 onself.cursor.style.bg_color != .none. Programs that reset attributes withESC[0m(which setsbg_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 sizesbun test lib/viewport-corruption.test.ts— viewport corruption regression tests passbun test— full suite passes🤖 Generated with Claude Code