From 35d26f1d271b226d03e37faf4628e22ca6899f55 Mon Sep 17 00:00:00 2001 From: irokas Date: Sun, 2 Jul 2017 14:22:24 +0300 Subject: [PATCH 1/2] Fix issue with small scrollback value. Closes #506 --- src/xterm.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/xterm.js b/src/xterm.js index 743ae7c5..f81085e7 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -419,6 +419,15 @@ Terminal.prototype.setOption = function(key, value) { } switch (key) { case 'scrollback': + if (value < this.rows) { + let msg = 'Setting the scrollback value less than the number of rows '; + + msg += `(${this.rows}) is not allowed.`; + + console.warn(msg); + return false; + } + if (this.options[key] !== value) { if (this.lines.length > value) { const amountToTrim = this.lines.length - value; From 3180a6f6ec24b2ecebfb6ab013f370f2397b1742 Mon Sep 17 00:00:00 2001 From: irokas Date: Sun, 2 Jul 2017 14:34:19 +0300 Subject: [PATCH 2/2] Add test for scrollback fix --- src/test/test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/test.js b/src/test/test.js index cad1dfc4..5e18397a 100644 --- a/src/test/test.js +++ b/src/test/test.js @@ -55,6 +55,11 @@ describe('xterm.js', function() { it('should throw when setting a non-existant option', function() { assert.throws(xterm.setOption.bind(xterm, 'fake', true)); }); + it('should not allow scrollback less than number of rows', function() { + let setOptionCall = xterm.setOption.bind(xterm, 'scrollback', xterm.rows - 1); + + assert.equal(setOptionCall(), false); + }); }); describe('clear', function() {