From 32c3cb01a1f3185c2f746f234523561e171107c6 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Tue, 30 Sep 2025 23:04:04 -0700 Subject: [PATCH 1/2] Make sure this._latestYDisp is up to date --- src/browser/Viewport.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 20e4db09d4..34880dee5c 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -157,9 +157,10 @@ export class Viewport extends Disposable { }); this._suppressOnScrollHandler = false; - // If ydisp has been changed by some other copmonent (input/buffer), then stop animating smooth + // If ydisp has been changed by some other component (input/buffer), then stop animating smooth // scroll and scroll there immediately. if (ydisp !== this._latestYDisp) { + this._latestYDisp = ydisp; this._scrollableElement.setScrollPosition({ scrollTop: ydisp * this._renderService.dimensions.css.cell.height }); From 2a6e22e8f88bc0cac523568a621a4b49a20ef0e2 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Wed, 1 Oct 2025 20:36:06 -0700 Subject: [PATCH 2/2] set this._latestYDisp = undefined onBufferActivate --- src/browser/Viewport.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 34880dee5c..1a9f222575 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -94,7 +94,12 @@ export class Viewport extends Disposable { })); this._register(this._bufferService.onResize(() => this.queueSync())); - this._register(this._bufferService.buffers.onBufferActivate(() => this.queueSync())); + this._register(this._bufferService.buffers.onBufferActivate(() => { + // Reset _latestYDisp when switching buffers to prevent stale scroll position + // from alt buffer contaminating normal buffer scroll position + this._latestYDisp = undefined; + this.queueSync(); + })); this._register(this._bufferService.onScroll(() => this._sync())); this._register(this._scrollableElement.onScroll(e => this._handleScroll(e))); @@ -160,7 +165,6 @@ export class Viewport extends Disposable { // If ydisp has been changed by some other component (input/buffer), then stop animating smooth // scroll and scroll there immediately. if (ydisp !== this._latestYDisp) { - this._latestYDisp = ydisp; this._scrollableElement.setScrollPosition({ scrollTop: ydisp * this._renderService.dimensions.css.cell.height });