diff --git a/fixtures/escape_sequence_files/t0070-DECSTBM_LF.in b/fixtures/escape_sequence_files/t0070-DECSTBM_LF.in index 571f2233..c56b99a0 100644 --- a/fixtures/escape_sequence_files/t0070-DECSTBM_LF.in +++ b/fixtures/escape_sequence_files/t0070-DECSTBM_LF.in @@ -27,5 +27,5 @@ r s t uvwxyz - + The end. diff --git a/fixtures/escape_sequence_files/t0070-DECSTBM_LF.text b/fixtures/escape_sequence_files/t0070-DECSTBM_LF.text index 0940b073..940bc86d 100644 --- a/fixtures/escape_sequence_files/t0070-DECSTBM_LF.text +++ b/fixtures/escape_sequence_files/t0070-DECSTBM_LF.text @@ -1,25 +1,25 @@ -1 - 2 - 6 - 7 - 8 - 9 ABC +6 +7 +8 +9 ABC DEF a - b - c - d - e - f - g - h - i - j - k - l - m - n - o - p -yz qrstu vwx +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +yz vwx The end. + diff --git a/fixtures/escape_sequence_files/t0071-DECSTBM_IND.in b/fixtures/escape_sequence_files/t0071-DECSTBM_IND.in index f9f6a424..a6aa1810 100644 --- a/fixtures/escape_sequence_files/t0071-DECSTBM_IND.in +++ b/fixtures/escape_sequence_files/t0071-DECSTBM_IND.in @@ -1,3 +1,3 @@ 1D2D3D4D5D6D7D8D9ABCDEFaDbDcDdDeDfDgDhDiDjDkDlDmDnDoDpDqDrDsDtDuvwxyz - + The end. diff --git a/fixtures/escape_sequence_files/t0071-DECSTBM_IND.text b/fixtures/escape_sequence_files/t0071-DECSTBM_IND.text index f6644fb5..bc7344f9 100644 --- a/fixtures/escape_sequence_files/t0071-DECSTBM_IND.text +++ b/fixtures/escape_sequence_files/t0071-DECSTBM_IND.text @@ -1,4 +1,3 @@ - 2 6 7 8 @@ -21,5 +20,6 @@ DEF o p q -The end. rstu vwx +yz rstu vwx +The end. diff --git a/fixtures/escape_sequence_files/t0076-DECSTBM_IL_DL.text b/fixtures/escape_sequence_files/t0076-DECSTBM_IL_DL.text index f89893ba..92c10331 100644 --- a/fixtures/escape_sequence_files/t0076-DECSTBM_IL_DL.text +++ b/fixtures/escape_sequence_files/t0076-DECSTBM_IL_DL.text @@ -1,4 +1,3 @@ - 6 C 8 ^^^^ 9 vvvv DL on line 11, expected: ACD_ 10 A @@ -13,14 +12,14 @@ 19 vvvv IL on line 21, expected: A_ 20 A - 22 ^^^^ -24 A -25 B -27 vvvv DL on line 28, expected: B_ +23 vvvv IL on line 24, expected: _A +25 B +26 ^^^^ 28 A + 29 B 30 ^^^^ 31 -32 \ No newline at end of file +32 diff --git a/fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.in b/fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.in new file mode 100644 index 00000000..b279f92a --- /dev/null +++ b/fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.in @@ -0,0 +1,24 @@ +a +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +r +s +t +u +v +w +x12 diff --git a/fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.text b/fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.text new file mode 100644 index 00000000..3acccf1a --- /dev/null +++ b/fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.text @@ -0,0 +1,25 @@ +a +b +c +d +e +f +g +h +i +2 +k +l +m +n +o +p +q +r +1 +t +u +v +w +x + diff --git a/fixtures/escape_sequence_files/t0079-DECSTBM_VPR.in b/fixtures/escape_sequence_files/t0079-DECSTBM_VPR.in new file mode 100644 index 00000000..f818ad7f --- /dev/null +++ b/fixtures/escape_sequence_files/t0079-DECSTBM_VPR.in @@ -0,0 +1,24 @@ +a +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +r +s +t +u +v +w +x1 diff --git a/fixtures/escape_sequence_files/t0079-DECSTBM_VPR.text b/fixtures/escape_sequence_files/t0079-DECSTBM_VPR.text new file mode 100644 index 00000000..a2d66f8e --- /dev/null +++ b/fixtures/escape_sequence_files/t0079-DECSTBM_VPR.text @@ -0,0 +1,25 @@ +a +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +r +s +t +u +v +w +x +1 diff --git a/src/InputHandler.ts b/src/InputHandler.ts index 83019c18..6a8e0ac6 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -429,10 +429,13 @@ export class InputHandler extends Disposable implements IInputHandler { if (wraparoundMode) { buffer.x = 0; buffer.y++; - if (buffer.y > buffer.scrollBottom) { + if (buffer.y === buffer.scrollBottom + 1) { buffer.y--; this._terminal.scroll(true); } else { + if (buffer.y >= this._bufferService.rows) { + buffer.y = this._bufferService.rows - 1; + } // The line already exists (eg. the initial viewport), mark it as a // wrapped line buffer.lines.get(buffer.y).isWrapped = true; @@ -539,9 +542,11 @@ export class InputHandler extends Disposable implements IInputHandler { buffer.x = 0; } buffer.y++; - if (buffer.y > buffer.scrollBottom) { + if (buffer.y === buffer.scrollBottom + 1) { buffer.y--; this._terminal.scroll(); + } else if (buffer.y >= this._bufferService.rows) { + buffer.y = this._bufferService.rows - 1; } // If the end of the line is hit, prevent this action from wrapping around to the next line. if (buffer.x >= this._bufferService.cols) { @@ -642,7 +647,13 @@ export class InputHandler extends Disposable implements IInputHandler { * Cursor Up Ps Times (default = 1) (CUU). */ public cursorUp(params: IParams): void { - this._moveCursor(0, -(params.params[0] || 1)); + // stop at scrollTop + const diffToTop = this._bufferService.buffer.y - this._bufferService.buffer.scrollTop; + if (diffToTop >= 0) { + this._moveCursor(0, -Math.min(diffToTop, params.params[0] || 1)); + } else { + this._moveCursor(0, -(params.params[0] || 1)); + } } /** @@ -650,7 +661,13 @@ export class InputHandler extends Disposable implements IInputHandler { * Cursor Down Ps Times (default = 1) (CUD). */ public cursorDown(params: IParams): void { - this._moveCursor(0, params.params[0] || 1); + // stop at scrollBottom + const diffToBottom = this._bufferService.buffer.scrollBottom - this._bufferService.buffer.y; + if (diffToBottom >= 0) { + this._moveCursor(0, Math.min(diffToBottom, params.params[0] || 1)); + } else { + this._moveCursor(0, params.params[0] || 1); + } } /** @@ -675,7 +692,7 @@ export class InputHandler extends Disposable implements IInputHandler { * Other than cursorDown (CUD) also set the cursor to first column. */ public cursorNextLine(params: IParams): void { - this._moveCursor(0, params.params[0] || 1); + this.cursorDown(params); this._bufferService.buffer.x = 0; } @@ -685,7 +702,7 @@ export class InputHandler extends Disposable implements IInputHandler { * Other than cursorUp (CUU) also set the cursor to first column. */ public cursorPrecedingLine(params: IParams): void { - this._moveCursor(0, -(params.params[0] || 1)); + this.cursorUp(params); this._bufferService.buffer.x = 0; } @@ -1027,7 +1044,7 @@ export class InputHandler extends Disposable implements IInputHandler { while (param--) { buffer.lines.splice(buffer.ybase + buffer.scrollTop, 1); - buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 0, buffer.getBlankLine(DEFAULT_ATTR_DATA)); + buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 0, buffer.getBlankLine(this._terminal.eraseAttrData())); } this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); } @@ -1044,7 +1061,7 @@ export class InputHandler extends Disposable implements IInputHandler { while (param--) { buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 1); - buffer.lines.splice(buffer.ybase + buffer.scrollTop, 0, buffer.getBlankLine(DEFAULT_ATTR_DATA)); + buffer.lines.splice(buffer.ybase + buffer.scrollTop, 0, buffer.getBlankLine(this._terminal.eraseAttrData())); } this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom); } @@ -2060,10 +2077,13 @@ export class InputHandler extends Disposable implements IInputHandler { */ public index(): void { this._restrictCursor(); + const buffer = this._bufferService.buffer; this._bufferService.buffer.y++; - if (this._bufferService.buffer.y > this._bufferService.buffer.scrollBottom) { - this._bufferService.buffer.y--; + if (buffer.y === buffer.scrollBottom + 1) { + buffer.y--; this._terminal.scroll(); + } else if (buffer.y >= this._bufferService.rows) { + buffer.y = this._bufferService.rows - 1; } this._restrictCursor(); } diff --git a/src/Terminal2.test.ts b/src/Terminal2.test.ts index cbd790d5..efb2a446 100644 --- a/src/Terminal2.test.ts +++ b/src/Terminal2.test.ts @@ -17,12 +17,6 @@ const ROWS = 25; const TESTFILES = glob.sync('**/escape_sequence_files/*.in', { cwd: path.join(__dirname, '..')}); const SKIP_FILES = [ - 't0070-DECSTBM_LF.in', // lineFeed not working correctly - 't0071-DECSTBM_IND.in', - 't0072-DECSTBM_NEL.in', - 't0075-DECSTBM_CUU_CUD.in', - 't0076-DECSTBM_IL_DL.in', // not working due to lineFeed - 't0077-DECSTBM_quirks.in', 't0084-CBT.in', 't0101-NLM.in', 't0103-reverse_wrap.in', @@ -42,7 +36,7 @@ const FILES = TESTFILES.filter(value => SKIP_FILES.indexOf(value.split('/').slic describe('Escape Sequence Files', function(): void { - this.timeout(20000); + this.timeout(1000); let ptyTerm: any; let slaveEnd: any; diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index e4c703eb..90c85ecd 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -563,9 +563,10 @@ export class SelectionService implements ISelectionService { // to be sent to the pty. event.stopImmediatePropagation(); - // Something went wrong + // Do nothing if there is no selection start, this can happen if the first + // click in the terminal is an incremental click if (!this._model.selectionStart) { - throw new Error('Selection start position was not set before mousemove event'); + return; } // Record the previous position so we know whether to redraw the selection