Merge pull request #749 from irokas/fix-scrollback

Fix issue with small scrollback value
This commit is contained in:
Paris Kasidiaris
2017-07-02 14:39:07 +03:00
committed by GitHub
2 changed files with 14 additions and 0 deletions
+5
View File
@@ -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() {
+9
View File
@@ -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;