From f5c3b00c42d7fbc0fcae5eaf1bafd90c02f40351 Mon Sep 17 00:00:00 2001 From: kumaran-14 Date: Fri, 10 Jan 2020 00:02:18 +0530 Subject: [PATCH 01/11] Fixes Alt + click behaviour when rows are wrapped --- src/browser/input/MoveToCell.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/browser/input/MoveToCell.ts b/src/browser/input/MoveToCell.ts index 406ec807..72a24280 100644 --- a/src/browser/input/MoveToCell.ts +++ b/src/browser/input/MoveToCell.ts @@ -30,7 +30,30 @@ export function moveToCellSequence(targetX: number, targetY: number, bufferServi } // Only move horizontally for the normal buffer - return moveHorizontallyOnly(startX, startY, targetX, targetY, bufferService, applicationCursor); + let direction; + if(startY == targetY) { + direction = startX > targetX ? Direction.LEFT : Direction.RIGHT; + return repeat(Math.abs(startX - targetX), sequence(direction, applicationCursor)); + } else { + direction = startY > targetY ? Direction.LEFT : Direction.RIGHT; + return repeat(colsFromRowEnd(startY > targetY ? targetX : startX, bufferService), sequence(direction, applicationCursor)) + + repeat((Math.abs(wrappedRowsForRow(bufferService, startY) - wrappedRowsForRow(bufferService, targetY))-1)*bufferService.cols, sequence(direction, applicationCursor)) + + repeat(colsFromRowBeginning(startY > targetY ? startX : targetX, bufferService), sequence(direction, applicationCursor)); + } +} + +/** + * Find the number of cols from a row beginning to a col. + */ +function colsFromRowBeginning(currX: number, bufferService: IBufferService): number { + return Math.abs(currX); +} + +/** + * Find the number of cols from a col to row end. + */ +function colsFromRowEnd(currX: number, bufferService: IBufferService): number { + return Math.abs(bufferService.cols - currX); } /** From 76d4de225a541d19be340e2d0bba7e423211f300 Mon Sep 17 00:00:00 2001 From: kumaran-14 Date: Fri, 10 Jan 2020 00:40:49 +0530 Subject: [PATCH 02/11] Run eslint and fix errors --- src/browser/input/MoveToCell.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/browser/input/MoveToCell.ts b/src/browser/input/MoveToCell.ts index 72a24280..9b493288 100644 --- a/src/browser/input/MoveToCell.ts +++ b/src/browser/input/MoveToCell.ts @@ -31,15 +31,14 @@ export function moveToCellSequence(targetX: number, targetY: number, bufferServi // Only move horizontally for the normal buffer let direction; - if(startY == targetY) { + if (startY === targetY) { direction = startX > targetX ? Direction.LEFT : Direction.RIGHT; return repeat(Math.abs(startX - targetX), sequence(direction, applicationCursor)); - } else { + } direction = startY > targetY ? Direction.LEFT : Direction.RIGHT; return repeat(colsFromRowEnd(startY > targetY ? targetX : startX, bufferService), sequence(direction, applicationCursor)) - + repeat((Math.abs(wrappedRowsForRow(bufferService, startY) - wrappedRowsForRow(bufferService, targetY))-1)*bufferService.cols, sequence(direction, applicationCursor)) + + repeat((Math.abs(wrappedRowsForRow(bufferService, startY) - wrappedRowsForRow(bufferService, targetY)) - 1 ) * bufferService.cols, sequence(direction, applicationCursor)) + repeat(colsFromRowBeginning(startY > targetY ? startX : targetX, bufferService), sequence(direction, applicationCursor)); - } } /** From af67b724923b04a47f3a506e7d0d388886915676 Mon Sep 17 00:00:00 2001 From: kumaran-14 Date: Wed, 15 Jan 2020 21:32:04 +0530 Subject: [PATCH 03/11] Fix unit tests for MoveToCellSequence --- src/browser/input/MoveToCell.test.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/browser/input/MoveToCell.test.ts b/src/browser/input/MoveToCell.test.ts index bc4012c0..b78748ba 100644 --- a/src/browser/input/MoveToCell.test.ts +++ b/src/browser/input/MoveToCell.test.ts @@ -23,15 +23,15 @@ describe('MoveToCell', () => { assert.equal(moveToCellSequence(4, 3, bufferService, false), '\x1b[C'); }); it('should ignore the Y value', () => { - assert.equal(moveToCellSequence(1, 1, bufferService, false), '\x1b[D\x1b[D'); - assert.equal(moveToCellSequence(1, 2, bufferService, false), '\x1b[D\x1b[D'); - assert.equal(moveToCellSequence(1, 3, bufferService, false), '\x1b[D\x1b[D'); - assert.equal(moveToCellSequence(1, 4, bufferService, false), '\x1b[D\x1b[D'); - assert.equal(moveToCellSequence(1, 5, bufferService, false), '\x1b[D\x1b[D'); + assert.equal(moveToCellSequence(1, 1, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D'); + assert.equal(moveToCellSequence(1, 2, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D'); + assert.equal(moveToCellSequence(1, 3, bufferService, false), '\u001b[D\u001b[D'); + assert.equal(moveToCellSequence(1, 4, bufferService, false), '\u001b[C\u001b[C\u001b[C'); + assert.equal(moveToCellSequence(1, 5, bufferService, false), '\u001b[C\u001b[C\u001b[C'); }); it('should use the correct character for application cursor', () => { - assert.equal(moveToCellSequence(2, 1, bufferService, false), '\x1b[D'); - assert.equal(moveToCellSequence(2, 1, bufferService, true), '\x1bOD'); + assert.equal(moveToCellSequence(2, 1, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D'); + assert.equal(moveToCellSequence(2, 1, bufferService, true), '\u001bOD\u001bOD\u001bOD\u001bOD\u001bOD\u001bOD'); }); }); From 6240a5d7a4d2a01cbc4746024810873c76a54cb9 Mon Sep 17 00:00:00 2001 From: Jeff Baier Date: Wed, 22 Jan 2020 14:16:39 -0600 Subject: [PATCH 04/11] Add _terminalClass identifier to cursor blink animation css so that multiple DOM rendered instances no longer lose the cursor theme color Fixes #2674 --- src/browser/renderer/dom/DomRenderer.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/browser/renderer/dom/DomRenderer.ts b/src/browser/renderer/dom/DomRenderer.ts index 5fbcfdc9..e8679026 100644 --- a/src/browser/renderer/dom/DomRenderer.ts +++ b/src/browser/renderer/dom/DomRenderer.ts @@ -173,13 +173,13 @@ export class DomRenderer extends Disposable implements IRenderer { `}`; // Blink animation styles += - `@keyframes blink_box_shadow {` + + `@keyframes blink_box_shadow` + `_` + this._terminalClass + ` {` + ` 50% {` + ` box-shadow: none;` + ` }` + `}`; styles += - `@keyframes blink_block {` + + `@keyframes blink_block` + `_` + this._terminalClass + ` {` + ` 0% {` + ` background-color: ${this._colors.cursor.css};` + ` color: ${this._colors.cursorAccent.css};` + @@ -196,10 +196,10 @@ export class DomRenderer extends Disposable implements IRenderer { ` outline-offset: -1px;` + `}` + `${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_BLINK_CLASS}:not(.${CURSOR_STYLE_BLOCK_CLASS}) {` + - ` animation: blink_box_shadow 1s step-end infinite;` + + ` animation: blink_box_shadow` + `_` + this._terminalClass + ` 1s step-end infinite;` + `}` + `${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_BLINK_CLASS}.${CURSOR_STYLE_BLOCK_CLASS} {` + - ` animation: blink_block 1s step-end infinite;` + + ` animation: blink_block` + `_` + this._terminalClass + ` 1s step-end infinite;` + `}` + `${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_BLOCK_CLASS} {` + ` background-color: ${this._colors.cursor.css};` + From 49bc27e24f7f13e45d387247bec0b7a2c84dfb19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sun, 2 Feb 2020 13:07:11 +0100 Subject: [PATCH 05/11] fixing visual repr chars --- src/common/data/Charsets.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/data/Charsets.ts b/src/common/data/Charsets.ts index 56ca6799..56513b8a 100644 --- a/src/common/data/Charsets.ts +++ b/src/common/data/Charsets.ts @@ -30,14 +30,14 @@ export const DEFAULT_CHARSET: ICharset | null = CHARSETS['B']; CHARSETS['0'] = { '`': '\u25c6', // '◆' 'a': '\u2592', // '▒' - 'b': '\u0009', // '\t' - 'c': '\u000c', // '\f' - 'd': '\u000d', // '\r' - 'e': '\u000a', // '\n' + 'b': '\u2409', // '␉' (HT) + 'c': '\u240c', // '␌' (FF) + 'd': '\u240d', // '␍' (CR) + 'e': '\u240a', // '␊' (LF) 'f': '\u00b0', // '°' 'g': '\u00b1', // '±' - 'h': '\u2424', // '\u2424' (NL) - 'i': '\u000b', // '\v' + 'h': '\u2424', // '␤' (NL) + 'i': '\u240b', // '␋' (VT) 'j': '\u2518', // '┘' 'k': '\u2510', // '┐' 'l': '\u250c', // '┌' From d5bf8966d9e6dad268346116d7878da58f9243b2 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sun, 2 Feb 2020 05:10:57 -0800 Subject: [PATCH 06/11] Remove ; and : from default wordSeparator Fixes #2665 --- src/common/services/OptionsService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index 7cd111ac..b855974a 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -52,7 +52,7 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({ screenKeys: false, cancelEvents: false, useFlowControl: false, - wordSeparator: ' ()[]{}\',:;"`' + wordSeparator: ' ()[]{}\',"`' }); /** From b591ccc40dcf9226da43ae63b30db7ec7b6cf370 Mon Sep 17 00:00:00 2001 From: kumaran-14 Date: Sun, 2 Feb 2020 23:28:24 +0530 Subject: [PATCH 07/11] Fix moveToCell when target is beyond buffer --- src/browser/input/MoveToCell.test.ts | 4 ++-- src/browser/input/MoveToCell.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/browser/input/MoveToCell.test.ts b/src/browser/input/MoveToCell.test.ts index b78748ba..735697d9 100644 --- a/src/browser/input/MoveToCell.test.ts +++ b/src/browser/input/MoveToCell.test.ts @@ -23,14 +23,14 @@ describe('MoveToCell', () => { assert.equal(moveToCellSequence(4, 3, bufferService, false), '\x1b[C'); }); it('should ignore the Y value', () => { - assert.equal(moveToCellSequence(1, 1, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D'); + assert.equal(moveToCellSequence(1, 1, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D'); assert.equal(moveToCellSequence(1, 2, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D'); assert.equal(moveToCellSequence(1, 3, bufferService, false), '\u001b[D\u001b[D'); assert.equal(moveToCellSequence(1, 4, bufferService, false), '\u001b[C\u001b[C\u001b[C'); assert.equal(moveToCellSequence(1, 5, bufferService, false), '\u001b[C\u001b[C\u001b[C'); }); it('should use the correct character for application cursor', () => { - assert.equal(moveToCellSequence(2, 1, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D'); + assert.equal(moveToCellSequence(2, 1, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D'); assert.equal(moveToCellSequence(2, 1, bufferService, true), '\u001bOD\u001bOD\u001bOD\u001bOD\u001bOD\u001bOD'); }); }); diff --git a/src/browser/input/MoveToCell.ts b/src/browser/input/MoveToCell.ts index 9b493288..e3b2555a 100644 --- a/src/browser/input/MoveToCell.ts +++ b/src/browser/input/MoveToCell.ts @@ -37,7 +37,7 @@ export function moveToCellSequence(targetX: number, targetY: number, bufferServi } direction = startY > targetY ? Direction.LEFT : Direction.RIGHT; return repeat(colsFromRowEnd(startY > targetY ? targetX : startX, bufferService), sequence(direction, applicationCursor)) - + repeat((Math.abs(wrappedRowsForRow(bufferService, startY) - wrappedRowsForRow(bufferService, targetY)) - 1 ) * bufferService.cols, sequence(direction, applicationCursor)) + + repeat((Math.abs(startY - targetY) - 1 ) * bufferService.cols, sequence(direction, applicationCursor)) + repeat(colsFromRowBeginning(startY > targetY ? startX : targetX, bufferService), sequence(direction, applicationCursor)); } From 7d84083f557e1cfd6ac04cc9c8c510afb3fdf036 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 3 Feb 2020 06:43:20 -0800 Subject: [PATCH 08/11] Fix algorithm to move the right amount of cells --- src/browser/input/MoveToCell.test.ts | 24 ++++++++++++++++-------- src/browser/input/MoveToCell.ts | 14 ++++++++------ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/browser/input/MoveToCell.test.ts b/src/browser/input/MoveToCell.test.ts index 735697d9..5753ea46 100644 --- a/src/browser/input/MoveToCell.test.ts +++ b/src/browser/input/MoveToCell.test.ts @@ -15,6 +15,9 @@ describe('MoveToCell', () => { bufferService = new MockBufferService(5, 5); bufferService.buffer.x = 3; bufferService.buffer.y = 3; + // Lines 2-4 are wrapped + bufferService.buffer.lines.get(3)!.isWrapped = true; + bufferService.buffer.lines.get(4)!.isWrapped = true; }); describe('normal buffer', () => { @@ -22,16 +25,21 @@ describe('MoveToCell', () => { assert.equal(moveToCellSequence(2, 3, bufferService, false), '\x1b[D'); assert.equal(moveToCellSequence(4, 3, bufferService, false), '\x1b[C'); }); - it('should ignore the Y value', () => { - assert.equal(moveToCellSequence(1, 1, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D'); - assert.equal(moveToCellSequence(1, 2, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D'); - assert.equal(moveToCellSequence(1, 3, bufferService, false), '\u001b[D\u001b[D'); - assert.equal(moveToCellSequence(1, 4, bufferService, false), '\u001b[C\u001b[C\u001b[C'); - assert.equal(moveToCellSequence(1, 5, bufferService, false), '\u001b[C\u001b[C\u001b[C'); + it('should wrap around entire row instead of doing up and down when the Y value differs', () => { + assert.equal(moveToCellSequence(2, 2, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D'); + assert.equal(moveToCellSequence(4, 4, bufferService, false), '\x1b[C\x1b[C\x1b[C'); + }); + it('should wrap across 2+ rows', () => { + bufferService.buffer.y = 2; + assert.equal(moveToCellSequence(3, 4, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D', '(3,2) to (3,4) = 10 cells'); + }); + it('should not move the cursor beyond the current wrapped row', () => { + assert.equal(moveToCellSequence(1, 1, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D'); + assert.equal(moveToCellSequence(1, 5, bufferService, false), '\x1b[C\x1b[C\x1b[C'); }); it('should use the correct character for application cursor', () => { - assert.equal(moveToCellSequence(2, 1, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D'); - assert.equal(moveToCellSequence(2, 1, bufferService, true), '\u001bOD\u001bOD\u001bOD\u001bOD\u001bOD\u001bOD'); + assert.equal(moveToCellSequence(2, 1, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D'); + assert.equal(moveToCellSequence(2, 1, bufferService, true), '\x1bOD\x1bOD\x1bOD\x1bOD\x1bOD\x1bOD'); }); }); diff --git a/src/browser/input/MoveToCell.ts b/src/browser/input/MoveToCell.ts index e3b2555a..1113f957 100644 --- a/src/browser/input/MoveToCell.ts +++ b/src/browser/input/MoveToCell.ts @@ -35,24 +35,26 @@ export function moveToCellSequence(targetX: number, targetY: number, bufferServi direction = startX > targetX ? Direction.LEFT : Direction.RIGHT; return repeat(Math.abs(startX - targetX), sequence(direction, applicationCursor)); } - direction = startY > targetY ? Direction.LEFT : Direction.RIGHT; - return repeat(colsFromRowEnd(startY > targetY ? targetX : startX, bufferService), sequence(direction, applicationCursor)) - + repeat((Math.abs(startY - targetY) - 1 ) * bufferService.cols, sequence(direction, applicationCursor)) - + repeat(colsFromRowBeginning(startY > targetY ? startX : targetX, bufferService), sequence(direction, applicationCursor)); + direction = startY > targetY ? Direction.LEFT : Direction.RIGHT; + const rowDifference = Math.abs(startY - targetY); + const cellsToMove = colsFromRowEnd(startY > targetY ? targetX : startX, bufferService) + + (rowDifference - 1) * bufferService.cols + 1/*wrap around 1 row*/ + + colsFromRowBeginning(startY > targetY ? startX : targetX, bufferService); + return repeat(cellsToMove, sequence(direction, applicationCursor)); } /** * Find the number of cols from a row beginning to a col. */ function colsFromRowBeginning(currX: number, bufferService: IBufferService): number { - return Math.abs(currX); + return currX - 1; } /** * Find the number of cols from a col to row end. */ function colsFromRowEnd(currX: number, bufferService: IBufferService): number { - return Math.abs(bufferService.cols - currX); + return bufferService.cols - currX; } /** From bb944f190e5f8e388128b655ece302bcbb69fc0b Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 3 Feb 2020 06:54:35 -0800 Subject: [PATCH 09/11] Fix and add more MoveToCell tests --- src/browser/input/MoveToCell.test.ts | 41 ++++++++++++++++++---------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/src/browser/input/MoveToCell.test.ts b/src/browser/input/MoveToCell.test.ts index 5753ea46..61e5f90b 100644 --- a/src/browser/input/MoveToCell.test.ts +++ b/src/browser/input/MoveToCell.test.ts @@ -15,31 +15,44 @@ describe('MoveToCell', () => { bufferService = new MockBufferService(5, 5); bufferService.buffer.x = 3; bufferService.buffer.y = 3; - // Lines 2-4 are wrapped - bufferService.buffer.lines.get(3)!.isWrapped = true; - bufferService.buffer.lines.get(4)!.isWrapped = true; }); describe('normal buffer', () => { it('should use the right directional escape sequences', () => { + assert.equal(moveToCellSequence(1, 3, bufferService, false), '\x1b[D\x1b[D'); assert.equal(moveToCellSequence(2, 3, bufferService, false), '\x1b[D'); assert.equal(moveToCellSequence(4, 3, bufferService, false), '\x1b[C'); + assert.equal(moveToCellSequence(5, 3, bufferService, false), '\x1b[C\x1b[C'); }); it('should wrap around entire row instead of doing up and down when the Y value differs', () => { - assert.equal(moveToCellSequence(2, 2, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D'); - assert.equal(moveToCellSequence(4, 4, bufferService, false), '\x1b[C\x1b[C\x1b[C'); - }); - it('should wrap across 2+ rows', () => { - bufferService.buffer.y = 2; - assert.equal(moveToCellSequence(3, 4, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D', '(3,2) to (3,4) = 10 cells'); - }); - it('should not move the cursor beyond the current wrapped row', () => { assert.equal(moveToCellSequence(1, 1, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D'); - assert.equal(moveToCellSequence(1, 5, bufferService, false), '\x1b[C\x1b[C\x1b[C'); + assert.equal(moveToCellSequence(2, 1, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D'); + assert.equal(moveToCellSequence(3, 1, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D'); + assert.equal(moveToCellSequence(4, 1, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D'); + assert.equal(moveToCellSequence(5, 1, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D'); + assert.equal(moveToCellSequence(1, 2, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D'); + assert.equal(moveToCellSequence(2, 2, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D'); + assert.equal(moveToCellSequence(3, 2, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D'); + assert.equal(moveToCellSequence(4, 2, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D'); + assert.equal(moveToCellSequence(5, 2, bufferService, false), '\x1b[D\x1b[D\x1b[D'); + assert.equal(moveToCellSequence(1, 4, bufferService, false), '\x1b[C\x1b[C\x1b[C'); + assert.equal(moveToCellSequence(2, 4, bufferService, false), '\x1b[C\x1b[C\x1b[C\x1b[C'); + assert.equal(moveToCellSequence(3, 4, bufferService, false), '\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C'); + assert.equal(moveToCellSequence(4, 4, bufferService, false), '\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C'); + assert.equal(moveToCellSequence(5, 4, bufferService, false), '\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C'); + assert.equal(moveToCellSequence(1, 5, bufferService, false), '\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C'); + assert.equal(moveToCellSequence(2, 5, bufferService, false), '\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C'); + assert.equal(moveToCellSequence(3, 5, bufferService, false), '\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C'); + assert.equal(moveToCellSequence(4, 5, bufferService, false), '\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C'); + assert.equal(moveToCellSequence(5, 5, bufferService, false), '\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C\x1b[C'); }); it('should use the correct character for application cursor', () => { - assert.equal(moveToCellSequence(2, 1, bufferService, false), '\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D\x1b[D'); - assert.equal(moveToCellSequence(2, 1, bufferService, true), '\x1bOD\x1bOD\x1bOD\x1bOD\x1bOD\x1bOD'); + assert.equal(moveToCellSequence(3, 1, bufferService, true), '\x1bOD\x1bOD\x1bOD\x1bOD\x1bOD\x1bOD\x1bOD\x1bOD\x1bOD\x1bOD'); + assert.equal(moveToCellSequence(3, 2, bufferService, true), '\x1bOD\x1bOD\x1bOD\x1bOD\x1bOD'); + assert.equal(moveToCellSequence(2, 3, bufferService, true), '\x1bOD'); + assert.equal(moveToCellSequence(4, 3, bufferService, true), '\x1bOC'); + assert.equal(moveToCellSequence(3, 4, bufferService, true), '\x1bOC\x1bOC\x1bOC\x1bOC\x1bOC'); + assert.equal(moveToCellSequence(3, 5, bufferService, true), '\x1bOC\x1bOC\x1bOC\x1bOC\x1bOC\x1bOC\x1bOC\x1bOC\x1bOC\x1bOC'); }); }); From 3d53847f30be8feb3b3ea5a8c504ec2e7181ae4a Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 3 Feb 2020 07:00:06 -0800 Subject: [PATCH 10/11] Return exit code in Linux unit tests Fixes #2681 --- azure-pipelines.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f6f892c7..e641e716 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,7 +27,9 @@ jobs: displayName: 'Install dependencies and build' - script: | yarn test-unit-coverage --forbid-only + EXIT_CODE=$? ./node_modules/.bin/nyc report --reporter=cobertura + exit $EXIT_CODE displayName: 'Unit tests' - script: yarn lint displayName: 'Lint' From 8093a5f4191cc58475dc13ad547fae9d02bf30f9 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 3 Feb 2020 07:02:14 -0800 Subject: [PATCH 11/11] Fix lint --- src/browser/input/MoveToCell.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/input/MoveToCell.ts b/src/browser/input/MoveToCell.ts index 1113f957..4a7b55aa 100644 --- a/src/browser/input/MoveToCell.ts +++ b/src/browser/input/MoveToCell.ts @@ -38,7 +38,7 @@ export function moveToCellSequence(targetX: number, targetY: number, bufferServi direction = startY > targetY ? Direction.LEFT : Direction.RIGHT; const rowDifference = Math.abs(startY - targetY); const cellsToMove = colsFromRowEnd(startY > targetY ? targetX : startX, bufferService) + - (rowDifference - 1) * bufferService.cols + 1/*wrap around 1 row*/ + + (rowDifference - 1) * bufferService.cols + 1 /*wrap around 1 row*/ + colsFromRowBeginning(startY > targetY ? startX : targetX, bufferService); return repeat(cellsToMove, sequence(direction, applicationCursor)); }