From 6cd5c2b8462c0c7a4ce898125a2fc7e0507fabc6 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 31 Jan 2017 21:02:55 -0800 Subject: [PATCH] Add null checks in eraseRight and eraseLeft Fixes #519 --- src/xterm.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/xterm.js b/src/xterm.js index f88c9452..ec4927c7 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -2159,14 +2159,14 @@ Terminal.prototype.nextStop = function(x) { * @param {number} y The line in which to operate. */ Terminal.prototype.eraseRight = function(x, y) { - var line = this.lines.get(this.ybase + y) - , ch = [this.eraseAttr(), ' ', 1]; // xterm - - + var line = this.lines.get(this.ybase + y); + if (!line) { + return; + } + var ch = [this.eraseAttr(), ' ', 1]; // xterm for (; x < this.cols; x++) { line[x] = ch; } - this.updateRange(y); }; @@ -2178,12 +2178,15 @@ Terminal.prototype.eraseRight = function(x, y) { * @param {number} y The line in which to operate. */ Terminal.prototype.eraseLeft = function(x, y) { - var line = this.lines.get(this.ybase + y) - , ch = [this.eraseAttr(), ' ', 1]; // xterm - + var line = this.lines.get(this.ybase + y); + if (!line) { + return; + } + var ch = [this.eraseAttr(), ' ', 1]; // xterm x++; - while (x--) line[x] = ch; - + while (x--) { + line[x] = ch; + } this.updateRange(y); };