Cleared terminal lines should have isWrapped reset

Fixes #1710
This commit is contained in:
Alex Ross
2018-10-01 13:34:13 -07:00
parent d4ec50e7de
commit 18871f0d3c
3 changed files with 22 additions and 4 deletions
+18 -3
View File
@@ -730,6 +730,21 @@ export class InputHandler extends Disposable implements IInputHandler {
); );
} }
/**
* Helper method to reset cells in a terminal row.
* The cell gets replaced with the eraseChar of the terminal and the isWrapped property is set to false.
* @param y row index
*/
private _resetBufferLine(y: number): void {
const line = this._terminal.buffer.lines.get(this._terminal.buffer.ybase + y);
line.replaceCells(
0,
this._terminal.cols,
[this._terminal.eraseAttr(), NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]
);
line.isWrapped = false;
}
/** /**
* CSI Ps J Erase in Display (ED). * CSI Ps J Erase in Display (ED).
* Ps = 0 -> Erase Below (default). * Ps = 0 -> Erase Below (default).
@@ -750,7 +765,7 @@ export class InputHandler extends Disposable implements IInputHandler {
this._terminal.updateRange(j); this._terminal.updateRange(j);
this._eraseInBufferLine(j++, this._terminal.buffer.x, this._terminal.cols); this._eraseInBufferLine(j++, this._terminal.buffer.x, this._terminal.cols);
for (; j < this._terminal.rows; j++) { for (; j < this._terminal.rows; j++) {
this._eraseInBufferLine(j, 0, this._terminal.cols); this._resetBufferLine(j);
} }
this._terminal.updateRange(j); this._terminal.updateRange(j);
break; break;
@@ -759,7 +774,7 @@ export class InputHandler extends Disposable implements IInputHandler {
this._terminal.updateRange(j); this._terminal.updateRange(j);
this._eraseInBufferLine(j, 0, this._terminal.buffer.x + 1); this._eraseInBufferLine(j, 0, this._terminal.buffer.x + 1);
while (j--) { while (j--) {
this._eraseInBufferLine(j, 0, this._terminal.cols); this._resetBufferLine(j);
} }
this._terminal.updateRange(0); this._terminal.updateRange(0);
break; break;
@@ -767,7 +782,7 @@ export class InputHandler extends Disposable implements IInputHandler {
j = this._terminal.rows; j = this._terminal.rows;
this._terminal.updateRange(j - 1); this._terminal.updateRange(j - 1);
while (j--) { while (j--) {
this._eraseInBufferLine(j, 0, this._terminal.cols); this._resetBufferLine(j);
} }
this._terminal.updateRange(0); this._terminal.updateRange(0);
break; break;
+1 -1
View File
@@ -191,7 +191,7 @@ export class SearchHelper implements ISearchHelper {
do { do {
const nextLine = this._terminal._core.buffer.lines.get(lineIndex + 1); const nextLine = this._terminal._core.buffer.lines.get(lineIndex + 1);
lineWrapsToNext = nextLine ? nextLine.isWrapped : false; lineWrapsToNext = nextLine ? nextLine.isWrapped : false;
lineString += this._terminal._core.buffer.translateBufferLineToString(lineIndex, !lineWrapsToNext && trimRight); lineString += this._terminal._core.buffer.translateBufferLineToString(lineIndex, !lineWrapsToNext && trimRight).substring(0, this._terminal.cols);
lineIndex++; lineIndex++;
} while (lineWrapsToNext); } while (lineWrapsToNext);
+3
View File
@@ -82,6 +82,9 @@ describe('search addon', () => {
expect(hello3).eql(undefined); expect(hello3).eql(undefined);
expect(llo).eql(undefined); expect(llo).eql(undefined);
expect(goodbye).eql({col: 0, row: 5, term: 'goodbye'}); expect(goodbye).eql({col: 0, row: 5, term: 'goodbye'});
term.core.resize(9, 5);
const hello0Resize = term.searchHelper.findInLine('Hello', 0);
expect(hello0Resize).eql({col: 8, row: 0, term: 'Hello'});
}); });
it('should respect search regex', () => { it('should respect search regex', () => {
search.apply(<any>MockTerminal); search.apply(<any>MockTerminal);