From 4a864e79dca09f911bde74a2daf3bf321cdad0b0 Mon Sep 17 00:00:00 2001 From: Jesse Grosjean Date: Mon, 30 Mar 2015 13:05:45 -0400 Subject: [PATCH] Fix screenPositionForPixelPosition for case above first row. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently screenPositionForPixelPosition special cases pixel positions below the last row so that the column position is always set to the last column of the last line, even if the pixel 'x' position is less then that column. This patch special cases picks above the first row so that the text column position will be in the first column even if the pixel 'x' position is greater then that column. At a higher level, this patch fixes the problem where you can’t select to the start of a text field by just clicking and dragging up. Instead you have to click and drag back (x axis) beyond the start of the text field. --- src/display-buffer.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/display-buffer.coffee b/src/display-buffer.coffee index b60113661..d79b1bce7 100644 --- a/src/display-buffer.coffee +++ b/src/display-buffer.coffee @@ -692,6 +692,7 @@ class DisplayBuffer extends Model targetLeft = pixelPosition.left defaultCharWidth = @defaultCharWidth row = Math.floor(targetTop / @getLineHeightInPixels()) + targetLeft = -Infinity if row < 0 targetLeft = Infinity if row > @getLastRow() row = Math.min(row, @getLastRow()) row = Math.max(0, row)