mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Merge pull request #749 from irokas/fix-scrollback
Fix issue with small scrollback value
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user