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() { 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;