From 79c07d436e5f5d6a5cb1f875dbafb7b51137b1f9 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 20 Sep 2017 11:53:19 +0900 Subject: [PATCH] Fix selection horizontal offset Fixes #1000 --- src/utils/Mouse.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/Mouse.ts b/src/utils/Mouse.ts index 7bc39b7fc..66e7f190a 100644 --- a/src/utils/Mouse.ts +++ b/src/utils/Mouse.ts @@ -49,7 +49,8 @@ export function getCoords(event: {pageX: number, pageY: number}, element: HTMLEl } // Convert to cols/rows. - coords[0] = Math.ceil((coords[0] + (isSelection ? charMeasure.width / 2 : 0)) / charMeasure.width); + const flooredCharWidth = Math.floor(charMeasure.width); + coords[0] = Math.ceil((coords[0] + (isSelection ? flooredCharWidth / 2 : 0)) / flooredCharWidth); coords[1] = Math.ceil(coords[1] / Math.ceil(charMeasure.height * lineHeight)); // Ensure coordinates are within the terminal viewport.