fix: preserve scroll position when terminal shrinks#638
Open
mekineer-com wants to merge 1 commit intolxqt:masterfrom
Open
fix: preserve scroll position when terminal shrinks#638mekineer-com wants to merge 1 commit intolxqt:masterfrom
mekineer-com wants to merge 1 commit intolxqt:masterfrom
Conversation
When the terminal's visible area shrinks, Screen::resizeImage() pushes excess screen lines into history to keep the cursor in view. However, ScreenWindow::notifyOutputChanged() did not adjust _currentLine for this history growth in the non-tracking-output path, causing the viewport to jump towards the top of the scrollback. This is noticeable in any layout where the terminal widget shares vertical space with another widget that can grow (e.g. a text editor strip), but also affects plain window resizes — shrinking a terminal window while scrolled up in the scrollback causes a visible position jump. Track the number of lines pushed to history during resizeImage() in a new _resizePushedLines counter. In the non-tracking path of notifyOutputChanged(), advance _currentLine by that amount so the bottom-visible line stays anchored. The counter accumulates across batched resizes and resets in showBulk() alongside scrolledLines and droppedLines.
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
Screen::resizeImage()pushes excess screen lines into history to keep the cursor in view.ScreenWindow::notifyOutputChanged()adjusts_currentLinefor dropped lines (history overflow) but not for these resize-pushed lines in the non-tracking-output path, causing the viewport to jump towards the top of the scrollback._resizePushedLinescounter, advance_currentLineby that amount in the non-tracking path, reset inshowBulk().Reproduction
Test plan