Skip to content

Commit f4badda

Browse files
authored
Merge pull request #5411 from xtermjs/anthonykim1/fixTeleportWhenAltScroll
Fix teleport when exiting out of alt buffer. v2
2 parents a1d8e96 + 2a6e22e commit f4badda

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/browser/Viewport.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ export class Viewport extends Disposable {
9494
}));
9595

9696
this._register(this._bufferService.onResize(() => this.queueSync()));
97-
this._register(this._bufferService.buffers.onBufferActivate(() => this.queueSync()));
97+
this._register(this._bufferService.buffers.onBufferActivate(() => {
98+
// Reset _latestYDisp when switching buffers to prevent stale scroll position
99+
// from alt buffer contaminating normal buffer scroll position
100+
this._latestYDisp = undefined;
101+
this.queueSync();
102+
}));
98103
this._register(this._bufferService.onScroll(() => this._sync()));
99104

100105
this._register(this._scrollableElement.onScroll(e => this._handleScroll(e)));
@@ -157,7 +162,7 @@ export class Viewport extends Disposable {
157162
});
158163
this._suppressOnScrollHandler = false;
159164

160-
// If ydisp has been changed by some other copmonent (input/buffer), then stop animating smooth
165+
// If ydisp has been changed by some other component (input/buffer), then stop animating smooth
161166
// scroll and scroll there immediately.
162167
if (ydisp !== this._latestYDisp) {
163168
this._scrollableElement.setScrollPosition({

0 commit comments

Comments
 (0)