You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Terminal scroll-to-top persists — happens after input, not just tab switching #573
After the fix in #560 (externally tracked scroll state) and #563 (safeFit condition fix), terminals still scroll to the top unexpectedly. The issue is NOT limited to tab switching — it can happen after every input in some terminals.
If baseY reads as 0 or undefined during a buffer reflow or mid-write, safeFit calls fitAddon.fit() WITHOUT scroll preservation. This is the unprotected path.
2. onScroll handler reads during reflow
The term.onScroll() handler (line 368-374) reads term.buffer.active.viewportY from the buffer. During fitAddon.fit() reflow, these values may be stale or intermediate, corrupting scrollState.
3. ResizeObserver triggering during writes
If terminal output causes subtle layout changes that trigger ResizeObserver → debouncedFit → safeFit, this could cause repeated scroll resets after every keystroke.
Reproduction
Use a terminal with significant scrollback history
Type commands — terminal may scroll to top after output arrives
More likely in terminals with active output
Suggested Investigation
Add console.log tracing in safeFit() — log baseY, scrollState, and whether the unprotected path is taken
Log when debouncedFit is triggered and by what (ResizeObserver vs visibilitychange)
Check if term.onScroll fires during fitAddon.fit() and what values it reports
Consider using scrollState.baseY as fallback when term.buffer.active.baseY returns 0/undefined
Activity
[Bugfix #573] Fix scroll-to-top: ignore onScroll events when containe…
[Bugfix #573] Add scroll-to-top auto-correction and improved reset de…
waleedkadous commentedon Mar 4, 2026
Significantly improved after the scroll-to-top fix. Closing as resolved.