Fix screenPositionForPixelPosition for case above first row.

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.
This commit is contained in:
Jesse Grosjean
2015-03-30 13:05:45 -04:00
parent f83f37b53d
commit 4a864e79dc

View File

@@ -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)