fix: always clear new row cells during scroll to prevent stale data#134
Draft
darrinm wants to merge 2 commits into
Draft
fix: always clear new row cells during scroll to prevent stale data#134darrinm wants to merge 2 commits into
darrinm wants to merge 2 commits into
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>
3 tasks
7 tasks
diegosouzapw
added a commit
to diegosouzapw/ghostty-web
that referenced
this pull request
May 24, 2026
) Ports fixes for upstream issues coder#138 and coder#139: Issue coder#139 (viewport corruption when viewport spans multiple pages): - renderStateGetViewport: replace per-row pages.pin(.active) calls with cached row pins from RenderState.row_data, matching the native renderer. Independent per-row pin resolution produced inconsistent results across page boundaries. - terminal_new_with_config: convert scrollback_limit from line count to bytes using page layout calculation (Terminal.init expects bytes, not lines). This makes the page-spanning condition much less frequent. Issue coder#138 (stale cell data visible after scroll with default cursor style): - cursorDownScroll in Screen.zig: make row clearing unconditional. The old check `if (bg_color != .none)` skipped clearing when cursor style was default (after ESC[0m), leaving stale cells from reused page memory visible on empty lines. Inspired by: coder#133 Inspired by: coder#134 Co-authored-by: Claude Opus 4.7 <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