Repository navigation
Sync the scrollbar position to the buffer after a resize - #6342
Open
YogiOnCode wants to merge 1 commit into
Open
YogiOnCode wants to merge 1 commit into
YogiOnCode wants to merge 1 commit into
Conversation
A resize can reflow the buffer and move ydisp without firing onScroll. The onResize handler synced against the remembered _latestYDisp, so _sync never moved the scrollbar and it kept the pixel offset from the old size. The next wheel tick then scrolled by the whole error (hundreds of lines). Clear _latestYDisp on resize, as onBufferActivate already does, so the queued sync reads ydisp from the buffer and sets the scroll position. Fixes xtermjs#6172
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.
Fixes #6172
A resize can reflow the buffer and move
ydispwithout firingonScroll.Viewport'sonResizehandler calledqueueSync(), which runs_sync(this._latestYDisp), and_synconly moves the scrollbar whenydisp !== this._latestYDisp. So after a terminal that had been scrolled up was resized, the scrollbar kept its pixel offset from the old size, and the next wheel tick scrolled by the whole difference (871 → 572 in the issue's repro).The fix clears
_latestYDispon resize, exactly as theonBufferActivatehandler right below already does. The queued sync then readsydispfrom the buffer and sets the scroll position. Resizes are still coalesced to one sync per frame; the only added work is onesetScrollPositionper resize frame. A smooth scroll in flight during a resize now ends at the buffer's position, which the issue argues a resize should do anyway.Tests
test/playwright/Terminal.test.ts(buffer›scrollbar follows viewportY after a resize reflows a scrolled-up buffer), following the issue's repro: 300 long lines at 60 cols, scroll up 20, resize to 120 and back, then check the scrollbar row equalsviewportY. Fails before the change, passes after.npm run test-unit: 2445 passing.lint-changesclean.npm run test-integration-chromium: core 428 passed; all addon suites pass exceptaddon-fit(5) andaddon-image(2), which fail identically on this machine without the change (Windows 11, local environment).