From c3f46e4a6b244b043eda721e8d9714b618897721 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 31 Dec 2016 07:05:06 -0800 Subject: [PATCH] Fix scroll in tmux with max scrollback I believe this is related to when scrollBottom is not the last row in the viewport Fixes #434 --- src/xterm.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/xterm.js b/src/xterm.js index 1d22065..6fddd11 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -1234,6 +1234,15 @@ Terminal.prototype.showCursor = function() { Terminal.prototype.scroll = function() { var row; + // Make room for the new row in lines + if (this.lines.length === this.lines.maxLength) { + this.lines.trimStart(1); + this.ybase--; + if (this.ydisp !== 0) { + this.ydisp--; + } + } + this.ybase++; // TODO: Why is this done twice? @@ -1248,13 +1257,6 @@ Terminal.prototype.scroll = function() { row -= this.rows - 1 - this.scrollBottom; if (row === this.lines.length) { - // Compensate ybase and ydisp if lines has hit the maximum buffer size - if (this.lines.length === this.lines.maxLength) { - this.ybase--; - if (this.ydisp !== 0) { - this.ydisp--; - } - } // Optimization: pushing is faster than splicing when they amount to the same behavior this.lines.push(this.blankLine()); } else {