Compare commits

...
3 Commits
Author SHA1 Message Date
Paris Kasidiaris ea07bf8f69 Bump version to 2.9.2
Signed-off-by: Paris Kasidiaris <paris@sourcelair.com>
2017-08-09 06:48:24 +00:00
Daniel Imms 0b1711fb79 Merge pull request #873 from Tyriar/860_resize_exception
Fix exception when resizing both dimensions
2017-08-08 18:03:02 -07:00
Daniel Imms bb526aaa88 Fix exception when resizing both dimensions
This happened because buffers now resize themselves but they were
relying on Terminal to give them a blank line. The blank line was
coming back with the old columns value, causing an NPE.

Fixes #860
2017-08-08 12:59:02 -07:00
9 changed files with 30 additions and 14 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xterm.js", "name": "xterm.js",
"version": "2.9.1", "version": "2.9.2",
"ignore": ["demo", "test", ".gitignore"], "ignore": ["demo", "test", ".gitignore"],
"main": [ "main": [
"dist/xterm.js", "dist/xterm.js",
+5 -4
View File
@@ -41,7 +41,7 @@ var Buffer = (function () {
var ch = [this._terminal.defAttr, ' ', 1]; var ch = [this._terminal.defAttr, ' ', 1];
for (var i = 0; i < this._lines.length; i++) { for (var i = 0; i < this._lines.length; i++) {
if (this._lines.get(i) === undefined) { if (this._lines.get(i) === undefined) {
this._lines.set(i, this._terminal.blankLine()); this._lines.set(i, this._terminal.blankLine(undefined, undefined, newCols));
} }
while (this._lines.get(i).length < newCols) { while (this._lines.get(i).length < newCols) {
this._lines.get(i).push(ch); this._lines.get(i).push(ch);
@@ -60,7 +60,7 @@ var Buffer = (function () {
} }
} }
else { else {
this._lines.push(this._terminal.blankLine()); this._lines.push(this._terminal.blankLine(undefined, undefined, newCols));
} }
} }
} }
@@ -4946,7 +4946,7 @@ Terminal.prototype.clear = function () {
Terminal.prototype.eraseLine = function (y) { Terminal.prototype.eraseLine = function (y) {
this.eraseRight(0, y); this.eraseRight(0, y);
}; };
Terminal.prototype.blankLine = function (cur, isWrapped) { Terminal.prototype.blankLine = function (cur, isWrapped, cols) {
var attr = cur var attr = cur
? this.eraseAttr() ? this.eraseAttr()
: this.defAttr; : this.defAttr;
@@ -4954,7 +4954,8 @@ Terminal.prototype.blankLine = function (cur, isWrapped) {
if (isWrapped) { if (isWrapped) {
line.isWrapped = isWrapped; line.isWrapped = isWrapped;
} }
for (; i < this.cols; i++) { cols = cols || this.cols;
for (; i < cols; i++) {
line[i] = ch; line[i] = ch;
} }
return line; return line;
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "xterm", "name": "xterm",
"description": "Full xterm terminal, in your browser", "description": "Full xterm terminal, in your browser",
"version": "2.9.1", "version": "2.9.2",
"ignore": [ "ignore": [
"demo", "demo",
"test", "test",
+11
View File
@@ -143,5 +143,16 @@ describe('Buffer', () => {
}); });
}); });
}); });
describe('row and column increased', () => {
it('should resize properly', () => {
buffer.fillViewportRows();
buffer.resize(INIT_COLS + 5, INIT_ROWS + 5);
assert.equal(buffer.lines.length, INIT_ROWS + 5);
for (let i = 0; i < INIT_ROWS + 5; i++) {
assert.equal(buffer.lines.get(i).length, INIT_COLS + 5);
}
});
});
}); });
}); });
+4 -2
View File
@@ -85,8 +85,10 @@ export class Buffer implements IBuffer {
if (this._terminal.cols < newCols) { if (this._terminal.cols < newCols) {
const ch: [number, string, number] = [this._terminal.defAttr, ' ', 1]; // does xterm use the default attr? const ch: [number, string, number] = [this._terminal.defAttr, ' ', 1]; // does xterm use the default attr?
for (let i = 0; i < this._lines.length; i++) { for (let i = 0; i < this._lines.length; i++) {
// TODO: This should be removed, with tests setup for the case that was
// causing the underlying bug, see https://github.com/sourcelair/xterm.js/issues/824
if (this._lines.get(i) === undefined) { if (this._lines.get(i) === undefined) {
this._lines.set(i, this._terminal.blankLine()); this._lines.set(i, this._terminal.blankLine(undefined, undefined, newCols));
} }
while (this._lines.get(i).length < newCols) { while (this._lines.get(i).length < newCols) {
this._lines.get(i).push(ch); this._lines.get(i).push(ch);
@@ -111,7 +113,7 @@ export class Buffer implements IBuffer {
} else { } else {
// Add a blank line if there is no buffer left at the top to scroll to, or if there // Add a blank line if there is no buffer left at the top to scroll to, or if there
// are blank lines after the cursor // are blank lines after the cursor
this._lines.push(this._terminal.blankLine()); this._lines.push(this._terminal.blankLine(undefined, undefined, newCols));
} }
} }
} }
+1 -1
View File
@@ -48,7 +48,7 @@ export interface ITerminal {
emit(event: string, data: any); emit(event: string, data: any);
reset(): void; reset(): void;
showCursor(): void; showCursor(): void;
blankLine(cur?: boolean, isWrapped?: boolean); blankLine(cur?: boolean, isWrapped?: boolean, cols?: number);
} }
export interface IBuffer { export interface IBuffer {
+3 -2
View File
@@ -43,9 +43,10 @@ export class MockTerminal implements ITerminal {
showCursor(): void { showCursor(): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
blankLine(cur?: boolean, isWrapped?: boolean) { blankLine(cur?: boolean, isWrapped?: boolean, cols?: number) {
const line = []; const line = [];
for (let i = 0; i < this.cols; i++) { cols = cols || this.cols;
for (let i = 0; i < cols; i++) {
line.push([0, ' ', 1]); line.push([0, ' ', 1]);
} }
return line; return line;
+3 -2
View File
@@ -2091,7 +2091,7 @@ Terminal.prototype.eraseLine = function(y) {
* @param {number} cur First bunch of data for each "blank" character. * @param {number} cur First bunch of data for each "blank" character.
* @param {boolean} isWrapped Whether the new line is wrapped from the previous line. * @param {boolean} isWrapped Whether the new line is wrapped from the previous line.
*/ */
Terminal.prototype.blankLine = function(cur, isWrapped) { Terminal.prototype.blankLine = function(cur, isWrapped, cols) {
var attr = cur var attr = cur
? this.eraseAttr() ? this.eraseAttr()
: this.defAttr; : this.defAttr;
@@ -2106,7 +2106,8 @@ Terminal.prototype.blankLine = function(cur, isWrapped) {
line.isWrapped = isWrapped; line.isWrapped = isWrapped;
} }
for (; i < this.cols; i++) { cols = cols || this.cols;
for (; i < cols; i++) {
line[i] = ch; line[i] = ch;
} }