mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Fix cursor so clicking the below the last line of text puts the cursor at
the end of the last line.
This commit is contained in:
committed by
Kevin Sawicki
parent
04bd602c23
commit
88a95ad06b
@@ -661,7 +661,9 @@ class DisplayBuffer extends Model
|
||||
targetTop = pixelPosition.top
|
||||
targetLeft = pixelPosition.left
|
||||
defaultCharWidth = @defaultCharWidth
|
||||
row = Math.floor(targetTop / @getLineHeightInPixels())
|
||||
rawRowCount = targetTop / @getLineHeightInPixels()
|
||||
isLastRow = rawRowCount > @getLastRow()
|
||||
row = Math.floor(rawRowCount)
|
||||
row = Math.min(row, @getLastRow())
|
||||
row = Math.max(0, row)
|
||||
|
||||
@@ -669,11 +671,14 @@ class DisplayBuffer extends Model
|
||||
column = 0
|
||||
for token in @tokenizedLineForScreenRow(row).tokens
|
||||
charWidths = @getScopedCharWidths(token.scopeDescriptor)
|
||||
for char in token.value
|
||||
charWidth = charWidths[char] ? defaultCharWidth
|
||||
break if targetLeft <= left + (charWidth / 2)
|
||||
left += charWidth
|
||||
column++
|
||||
if !isLastRow
|
||||
for char in token.value
|
||||
charWidth = charWidths[char] ? defaultCharWidth
|
||||
break if targetLeft <= left + (charWidth / 2)
|
||||
left += charWidth
|
||||
column++
|
||||
else
|
||||
column = token.value.length
|
||||
|
||||
new Point(row, column)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user