From be56c72b5f05426f8e573c4135fa5e2af30fa77d Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 21 Dec 2016 15:43:04 -0800 Subject: [PATCH] Fix when scrollback limit is reached --- src/utils/CircularList.ts | 5 ----- src/xterm.js | 19 ++++--------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/utils/CircularList.ts b/src/utils/CircularList.ts index 90659544..a131bcbd 100644 --- a/src/utils/CircularList.ts +++ b/src/utils/CircularList.ts @@ -93,11 +93,6 @@ export class CircularList { return this._array[this._getCyclicIndex(this._length-- - 1)]; } - public removeItemsFromStart(amount: number): void { - this._startIndex += this._length -amount; - this._length = amount; - } - // TODO: Warn there's no error handling and that this is a slow operation public splice(start: number, deleteCount: number, ...items: T[]) { if (deleteCount) { diff --git a/src/xterm.js b/src/xterm.js index 813c720a..2cf0651c 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -1226,15 +1226,13 @@ Terminal.prototype.showCursor = function() { }; /** - * Scroll the terminal + * Scroll the terminal down 1 row, creating a blank line. */ Terminal.prototype.scroll = function() { var row; - if (++this.ybase === this.scrollback) { - this.ybase = this.ybase / 2; - // TODO: Rely on the circular list instead of cutting it in half - this.lines.removeItemsFromStart(this.ybase + this.rows - 1); + if (this.lines.length < this.lines.maxLength) { + this.ybase++; } if (!this.userScrolling) { @@ -1247,16 +1245,7 @@ Terminal.prototype.scroll = function() { // subtract the bottom scroll region row -= this.rows - 1 - this.scrollBottom; - if (row === this.lines.length) { - // potential optimization: - // pushing is faster than splicing - // when they amount to the same - // behavior. - this.lines.push(this.blankLine()); - } else { - // add our new line - this.lines.splice(row, 0, this.blankLine()); - } + this.lines.push(this.blankLine()); if (this.scrollTop !== 0) { if (this.ybase !== 0) {