Fix when scrollback limit is reached
This commit is contained in:
@@ -93,11 +93,6 @@ export class CircularList<T> {
|
|||||||
return this._array[this._getCyclicIndex(this._length-- - 1)];
|
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
|
// TODO: Warn there's no error handling and that this is a slow operation
|
||||||
public splice(start: number, deleteCount: number, ...items: T[]) {
|
public splice(start: number, deleteCount: number, ...items: T[]) {
|
||||||
if (deleteCount) {
|
if (deleteCount) {
|
||||||
|
|||||||
+4
-15
@@ -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() {
|
Terminal.prototype.scroll = function() {
|
||||||
var row;
|
var row;
|
||||||
|
|
||||||
if (++this.ybase === this.scrollback) {
|
if (this.lines.length < this.lines.maxLength) {
|
||||||
this.ybase = this.ybase / 2;
|
this.ybase++;
|
||||||
// TODO: Rely on the circular list instead of cutting it in half
|
|
||||||
this.lines.removeItemsFromStart(this.ybase + this.rows - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.userScrolling) {
|
if (!this.userScrolling) {
|
||||||
@@ -1247,16 +1245,7 @@ Terminal.prototype.scroll = function() {
|
|||||||
// subtract the bottom scroll region
|
// subtract the bottom scroll region
|
||||||
row -= this.rows - 1 - this.scrollBottom;
|
row -= this.rows - 1 - this.scrollBottom;
|
||||||
|
|
||||||
if (row === this.lines.length) {
|
this.lines.push(this.blankLine());
|
||||||
// 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());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.scrollTop !== 0) {
|
if (this.scrollTop !== 0) {
|
||||||
if (this.ybase !== 0) {
|
if (this.ybase !== 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user