From 610597530867e10fb91baf85d65cadf6c38c214a Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 1 Feb 2018 10:24:17 -0800 Subject: [PATCH] Ensure viewport is attached before syncing scrollbar Fixes #1265 --- src/Viewport.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Viewport.ts b/src/Viewport.ts index 87ecd69e..59dc304d 100644 --- a/src/Viewport.ts +++ b/src/Viewport.ts @@ -93,6 +93,12 @@ export class Viewport implements IViewport { * @param ev The scroll event. */ private onScroll(ev: Event): void { + // Don't attempt to scroll if the element is not visible, otherwise scrollTop will be corrupt + // which causes the terminal to scroll the buffer to the top + if (!this.viewportElement.offsetParent) { + return; + } + const newRow = Math.round(this.viewportElement.scrollTop / this.currentRowHeight); const diff = newRow - this.terminal.buffer.ydisp; this.terminal.scrollLines(diff, true);