From d8eedfa1c774415074837a66cd3107d706b42189 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 31 Jul 2018 10:56:37 -0700 Subject: [PATCH 1/3] Fix bug in column selection rendering Fixes #1593 --- src/renderer/SelectionRenderLayer.ts | 2 +- src/renderer/dom/DomRenderer.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer/SelectionRenderLayer.ts b/src/renderer/SelectionRenderLayer.ts index 12589aa0..81782ee8 100644 --- a/src/renderer/SelectionRenderLayer.ts +++ b/src/renderer/SelectionRenderLayer.ts @@ -72,7 +72,7 @@ export class SelectionRenderLayer extends BaseRenderLayer { this._ctx.fillStyle = this._colors.selection.css; if (columnSelectMode) { - const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0; + const startCol = start[0]; const width = end[0] - startCol; const height = viewportCappedEndRow - viewportCappedStartRow + 1; this.fillCells(startCol, viewportCappedStartRow, width, height); diff --git a/src/renderer/dom/DomRenderer.ts b/src/renderer/dom/DomRenderer.ts index e336c79e..2679e88e 100644 --- a/src/renderer/dom/DomRenderer.ts +++ b/src/renderer/dom/DomRenderer.ts @@ -241,14 +241,14 @@ export class DomRenderer extends EventEmitter implements IRenderer { // Create the selections const documentFragment = document.createDocumentFragment(); - const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0; if (columnSelectMode) { documentFragment.appendChild( - this._createSelectionElement(viewportCappedStartRow, startCol, end[0], viewportCappedEndRow - viewportStartRow + 1) + this._createSelectionElement(viewportCappedStartRow, start[0], end[0], viewportCappedEndRow - viewportCappedStartRow + 1) ); } else { // Draw first row + const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0; const endCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : this._terminal.cols; documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow, startCol, endCol)); // Draw middle rows From 7675be7da3ce4058dfef0ef3dae231f7311d6a81 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 6 Aug 2018 11:13:56 -0700 Subject: [PATCH 2/3] Fix dragging when in column selection mode --- src/SelectionManager.ts | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index 3731eb9a..a933b288 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -576,11 +576,14 @@ export class SelectionManager extends EventEmitter implements ISelectionManager this._dragScrollAmount = this._getMouseEventScrollAmount(event); // If the cursor was above or below the viewport, make sure it's at the - // start or end of the viewport respectively. - if (this._dragScrollAmount > 0) { - this._model.selectionEnd[0] = this._terminal.cols; - } else if (this._dragScrollAmount < 0) { - this._model.selectionEnd[0] = 0; + // start or end of the viewport respectively. This should only happen when + // NOT in column select mode. + if (this._activeSelectionMode !== SelectionMode.COLUMN) { + if (this._dragScrollAmount > 0) { + this._model.selectionEnd[0] = this._terminal.cols; + } else if (this._dragScrollAmount < 0) { + this._model.selectionEnd[0] = 0; + } } // If the character is a wide character include the cell to the right in the @@ -609,10 +612,19 @@ export class SelectionManager extends EventEmitter implements ISelectionManager if (this._dragScrollAmount) { this._terminal.scrollLines(this._dragScrollAmount, false); // Re-evaluate selection + // If the cursor was above or below the viewport, make sure it's at the + // start or end of the viewport respectively. This should only happen when + // NOT in column select mode. if (this._dragScrollAmount > 0) { - this._model.selectionEnd = [this._terminal.cols - 1, Math.min(this._terminal.buffer.ydisp + this._terminal.rows, this._terminal.buffer.lines.length - 1)]; + if (this._activeSelectionMode !== SelectionMode.COLUMN) { + this._model.selectionEnd[0] = this._terminal.cols - 1; + } + this._model.selectionEnd[1] = Math.min(this._terminal.buffer.ydisp + this._terminal.rows, this._terminal.buffer.lines.length - 1); } else { - this._model.selectionEnd = [0, this._terminal.buffer.ydisp]; + if (this._activeSelectionMode !== SelectionMode.COLUMN) { + this._model.selectionEnd[0] = 0; + } + this._model.selectionEnd[1] = this._terminal.buffer.ydisp; } this.refresh(); } From c9ec7aa2155b93add8c591a357d58e07bdb32cd7 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 6 Aug 2018 11:17:28 -0700 Subject: [PATCH 3/3] Fix flickering when dragging below viewport --- src/SelectionManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index a933b288..7f7204fc 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -617,7 +617,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager // NOT in column select mode. if (this._dragScrollAmount > 0) { if (this._activeSelectionMode !== SelectionMode.COLUMN) { - this._model.selectionEnd[0] = this._terminal.cols - 1; + this._model.selectionEnd[0] = this._terminal.cols; } this._model.selectionEnd[1] = Math.min(this._terminal.buffer.ydisp + this._terminal.rows, this._terminal.buffer.lines.length - 1); } else {