From 4f5f6e1fd29d7891c043417c2aac4d3fad9fe2c9 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sun, 30 Sep 2018 09:38:57 -0700 Subject: [PATCH] Get correct col/row coords from mouse event Before the y from getCoords could be -1, a ceil call was also causing a single pixel offset in each dimension Related Microsoft/vscode#50128 --- src/utils/MouseHelper.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/MouseHelper.ts b/src/utils/MouseHelper.ts index 15f0574266..44bd6f7b9b 100644 --- a/src/utils/MouseHelper.ts +++ b/src/utils/MouseHelper.ts @@ -32,7 +32,7 @@ export class MouseHelper { y += element.scrollTop; element = element.parentElement; } - return [x, y]; + return [x, y + 1]; } /** @@ -59,8 +59,8 @@ export class MouseHelper { return null; } - coords[0] = Math.ceil((coords[0] + (isSelection ? this._renderer.dimensions.actualCellWidth / 2 : 0)) / this._renderer.dimensions.actualCellWidth); - coords[1] = Math.ceil(coords[1] / this._renderer.dimensions.actualCellHeight); + coords[0] = Math.floor((coords[0] + (isSelection ? this._renderer.dimensions.actualCellWidth / 2 : 0)) / this._renderer.dimensions.actualCellWidth) + 1; + coords[1] = Math.floor(coords[1] / this._renderer.dimensions.actualCellHeight) + 1; // Ensure coordinates are within the terminal viewport. Note that selections // need an addition point of precision to cover the end point (as characters