From 0958f0ef912265281c4483683fac02f30d7f5a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Fri, 2 Aug 2019 15:29:26 +0200 Subject: [PATCH 1/8] fix DECSTBM with LF --- .../escape_sequence_files/t0070-DECSTBM_LF.in | 2 +- .../t0070-DECSTBM_LF.text | 44 +++++++++---------- src/InputHandler.ts | 9 +++- src/Terminal2.test.ts | 4 +- 4 files changed, 32 insertions(+), 27 deletions(-) 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/src/InputHandler.ts b/src/InputHandler.ts index f47085d4..0b011e34 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -412,10 +412,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; @@ -508,9 +511,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) { diff --git a/src/Terminal2.test.ts b/src/Terminal2.test.ts index cbd790d5..05018f0f 100644 --- a/src/Terminal2.test.ts +++ b/src/Terminal2.test.ts @@ -17,7 +17,7 @@ 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 + // 't0070-DECSTBM_LF.in', // lineFeed not working correctly 't0071-DECSTBM_IND.in', 't0072-DECSTBM_NEL.in', 't0075-DECSTBM_CUU_CUD.in', @@ -42,7 +42,7 @@ const FILES = TESTFILES.filter(value => SKIP_FILES.indexOf(value.split('/').slic describe('Escape Sequence Files', function(): void { - this.timeout(20000); + this.timeout(100); let ptyTerm: any; let slaveEnd: any; From 84d759150650fceb2324f6ab0180ab7fdc290580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Fri, 2 Aug 2019 21:06:16 +0200 Subject: [PATCH 2/8] increase test timeout --- src/Terminal2.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Terminal2.test.ts b/src/Terminal2.test.ts index 05018f0f..594558fb 100644 --- a/src/Terminal2.test.ts +++ b/src/Terminal2.test.ts @@ -42,7 +42,7 @@ const FILES = TESTFILES.filter(value => SKIP_FILES.indexOf(value.split('/').slic describe('Escape Sequence Files', function(): void { - this.timeout(100); + this.timeout(1000); let ptyTerm: any; let slaveEnd: any; From 497a5e6e84011fbb7719b7d47a904be15fd6373f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sat, 3 Aug 2019 15:00:30 +0200 Subject: [PATCH 3/8] fix DECSTBM with IND --- fixtures/escape_sequence_files/t0071-DECSTBM_IND.in | 2 +- fixtures/escape_sequence_files/t0071-DECSTBM_IND.text | 4 ++-- src/InputHandler.ts | 7 +++++-- src/Terminal2.test.ts | 2 -- 4 files changed, 8 insertions(+), 7 deletions(-) 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/src/InputHandler.ts b/src/InputHandler.ts index 0b011e34..f243433a 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -2048,10 +2048,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 594558fb..0638e316 100644 --- a/src/Terminal2.test.ts +++ b/src/Terminal2.test.ts @@ -17,8 +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 From eccd6d7bdf822d58bc14c97706b3fe3d29f3a5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sat, 3 Aug 2019 15:05:44 +0200 Subject: [PATCH 4/8] enable NEL test --- src/Terminal2.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Terminal2.test.ts b/src/Terminal2.test.ts index 0638e316..f87ecd3a 100644 --- a/src/Terminal2.test.ts +++ b/src/Terminal2.test.ts @@ -17,7 +17,6 @@ const ROWS = 25; const TESTFILES = glob.sync('**/escape_sequence_files/*.in', { cwd: path.join(__dirname, '..')}); const SKIP_FILES = [ - 't0072-DECSTBM_NEL.in', 't0075-DECSTBM_CUU_CUD.in', 't0076-DECSTBM_IL_DL.in', // not working due to lineFeed 't0077-DECSTBM_quirks.in', From 00298531ed9b1a742c8161baaadf427551e4976d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sun, 4 Aug 2019 12:20:44 +0200 Subject: [PATCH 5/8] respect scroll margins in CUU/CUD/CPL/CNL; test files --- .../t0078-DECSTBM_CPL_CNL.in | 24 ++++++++++++++++++ .../t0078-DECSTBM_CPL_CNL.text | 25 +++++++++++++++++++ .../t0079-DECSTBM_VPR.in | 24 ++++++++++++++++++ .../t0079-DECSTBM_VPR.text | 25 +++++++++++++++++++ src/InputHandler.ts | 20 ++++++++++++--- src/Terminal2.test.ts | 1 - 6 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.in create mode 100644 fixtures/escape_sequence_files/t0078-DECSTBM_CPL_CNL.text create mode 100644 fixtures/escape_sequence_files/t0079-DECSTBM_VPR.in create mode 100644 fixtures/escape_sequence_files/t0079-DECSTBM_VPR.text 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 f243433a..746f4345 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -616,7 +616,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)); + } } /** @@ -624,7 +630,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); + } } /** @@ -649,7 +661,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; } @@ -659,7 +671,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; } diff --git a/src/Terminal2.test.ts b/src/Terminal2.test.ts index f87ecd3a..2462fb19 100644 --- a/src/Terminal2.test.ts +++ b/src/Terminal2.test.ts @@ -17,7 +17,6 @@ const ROWS = 25; const TESTFILES = glob.sync('**/escape_sequence_files/*.in', { cwd: path.join(__dirname, '..')}); const SKIP_FILES = [ - 't0075-DECSTBM_CUU_CUD.in', 't0076-DECSTBM_IL_DL.in', // not working due to lineFeed 't0077-DECSTBM_quirks.in', 't0084-CBT.in', From 6285cbf9764e4c93ff87beec65de90dfceb3c064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sun, 4 Aug 2019 13:46:37 +0200 Subject: [PATCH 6/8] fix IL/DL test --- .../escape_sequence_files/t0076-DECSTBM_IL_DL.text | 11 +++++------ src/Terminal2.test.ts | 2 -- 2 files changed, 5 insertions(+), 8 deletions(-) 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/src/Terminal2.test.ts b/src/Terminal2.test.ts index 2462fb19..efb2a446 100644 --- a/src/Terminal2.test.ts +++ b/src/Terminal2.test.ts @@ -17,8 +17,6 @@ const ROWS = 25; const TESTFILES = glob.sync('**/escape_sequence_files/*.in', { cwd: path.join(__dirname, '..')}); const SKIP_FILES = [ - 't0076-DECSTBM_IL_DL.in', // not working due to lineFeed - 't0077-DECSTBM_quirks.in', 't0084-CBT.in', 't0101-NLM.in', 't0103-reverse_wrap.in', From 4200e8356bbfec6314ec412941472bbb0ecf1671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sun, 4 Aug 2019 17:07:56 +0200 Subject: [PATCH 7/8] apply BCE to SU/SD --- src/InputHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/InputHandler.ts b/src/InputHandler.ts index 746f4345..381671e0 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -1013,7 +1013,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); } @@ -1030,7 +1030,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); } From 29d8493a7a085263dd11422d72410dcaf5012fd6 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 7 Aug 2019 07:18:27 -0700 Subject: [PATCH 8/8] Don't throw if first click is incremental Fixes #2365 --- src/browser/services/SelectionService.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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