diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index 7b377a47..02f74ce8 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -30,6 +30,7 @@ export class Viewport extends Disposable implements IViewport { private _wheelPartialScroll: number = 0; private _refreshAnimationFrame: number | null = null; + private _ignoreNextScrollEvent: boolean = false; constructor( private readonly _scrollLines: (amount: number) => void, @@ -87,12 +88,14 @@ export class Viewport extends Disposable implements IViewport { // Sync scrollTop const scrollTop = this._bufferService.buffer.ydisp * this._currentRowHeight; if (this._viewportElement.scrollTop !== scrollTop) { + // Ignore the next scroll event which will be triggered by setting the scrollTop as we do not + // want this event to scroll the terminal + this._ignoreNextScrollEvent = true; this._viewportElement.scrollTop = scrollTop; } this._refreshAnimationFrame = null; } - /** * Updates dimensions and synchronizes the scroll area if necessary. */ @@ -145,6 +148,12 @@ export class Viewport extends Disposable implements IViewport { return; } + // Ignore the event if it was flagged to ignore (when the source of the event is from Viewport) + if (this._ignoreNextScrollEvent) { + this._ignoreNextScrollEvent = false; + return; + } + const newRow = Math.round(this._lastScrollTop / this._currentRowHeight); const diff = newRow - this._bufferService.buffer.ydisp; this._scrollLines(diff);