fix: reset viewport on window resize to prevent content jump and loss#294
Closed
CoderGoGoGo wants to merge 1 commit intotw93:mainfrom
Closed
fix: reset viewport on window resize to prevent content jump and loss#294CoderGoGoGo wants to merge 1 commit intotw93:mainfrom
CoderGoGoGo wants to merge 1 commit intotw93:mainfrom
Conversation
When the terminal window is resized, physical_top shifts because the number of lines and visible rows both change. However, the stored viewport position (PaneState::viewport) was never adjusted, causing: 1. Content appears to "jump" upward on resize 2. Unable to scroll up to see previous content 3. Repeated resizes progressively clear terminal content Two fixes applied: - Reset all pane viewports to bottom (None) after every resize in apply_dimensions(). This ensures users always see the latest output after a resize, regardless of live-resize or final resize. - Limit the pre-prune blank line removal in Screen::resize() to at most lines.len() - physical_rows lines. Previously the loop could remove all blank lines below the cursor without limit, which combined with repeated resizes caused cumulative content loss. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Owner
|
@CoderGoGoGo 感谢 PR,问题定位是对的。调整了一下 viewport 的处理方式:resize 后对已有 viewport 做 normalize 而不是直接重置为 None,这样用户在查看历史内容时 resize 不会被拉回底部。pre-prune 的上限逻辑保留了你的思路。已合入 main。 |
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
apply_dimensions(), preventing content from appearing to jump or becoming inaccessibleScreen::resize()to avoid cumulative content loss during repeated resizesProblem
When resizing the terminal window:
Root Cause
physical_topshifts on resize because bothlines.len()andphysical_rowschange, butPaneState::viewportwas never adjusted. Additionally, the pre-prune loop inScreen::resize()had no upper bound, causing cumulative content loss.Test Plan
🤖 Generated with Claude Code