Skip to content

macOS: don't yank the viewport to the bottom while scrolled up - #579

Closed
gilbert-barajas wants to merge 2 commits into
migueldeicaza:mainfrom
gilbert-barajas:fix-viewport-scroll-while-scrolled-up
Closed

macOS: don't yank the viewport to the bottom while scrolled up#579
gilbert-barajas wants to merge 2 commits into
migueldeicaza:mainfrom
gilbert-barajas:fix-viewport-scroll-while-scrolled-up

Conversation

@gilbert-barajas

Copy link
Copy Markdown

Problem

When new output arrives while the user has scrolled up into the scrollback, the viewport jumps back to the bottom — yanking them away from what they were reading. Follow-tail should only auto-scroll when the viewport is already pinned to the bottom.

Fix

Follow the tail (auto-scroll on new output) only when the user is already at the bottom; otherwise preserve the current scroll position.

Tests

TerminalFollowTailTests covers both the scrolled-up case (position preserved) and the at-bottom case (follows new output).

Note

Split out of #555 (live-resize reflow) for review hygiene — it was an unrelated change riding along. Includes a one-line SyncDebug no-op so the package builds (it's referenced on main but never committed); that build-unblocker is shared with #555 and will drop out on rebase once either lands.

gilbert-barajas and others added 2 commits June 22, 2026 13:58
…ring commit but never committed, broke the build

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Root cause: the macOS view never set Terminal.userScrolling — the only flag the
feed consults (Terminal.swift:5378 'if !userScrolling { yDisp = yBase }') — so
every line of output forced the viewport to the bottom. scrollTo(row:) now drives
userScrolling from the scroll position (parked above bottom => true, at bottom =>
false). Typing already routes through ensureCaretIsVisible -> scrollTo(yBase),
which clears it. Headless test reproduces the yank and verifies the hold.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@migueldeicaza

Copy link
Copy Markdown
Owner

Mhm, we have had a few attempts at addressing this, let me see if I can find my notes on the other attempts - although I think they were mostly iOS based.

@migueldeicaza

Copy link
Copy Markdown
Owner

I took a look at this, since I had a previous effort in a branch, but it was not quite complete and needed a few tuneups. I am happy now with what we have in iOS and I think it works fine on MacOS, can you take it for a spin? I think this is now fixed.

If it is not, please reopen the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants