mirror of
https://github.com/atom/atom.git
synced 2026-02-07 13:14:55 -05:00
Compare against EOF position when clipping
Previously the column could potentially be set to zero since a Math.min comparison was used for the length of an already adjusted row.
This commit is contained in:
@@ -212,13 +212,15 @@ class Buffer
|
||||
range
|
||||
|
||||
clipPosition: (position) ->
|
||||
{ row, column } = Point.fromObject(position)
|
||||
row = 0 if row < 0
|
||||
column = 0 if column < 0
|
||||
row = Math.min(@getLastRow(), row)
|
||||
column = Math.min(@lineLengthForRow(row), column)
|
||||
|
||||
new Point(row, column)
|
||||
position = Point.fromObject(position)
|
||||
eofPosition = @getEofPosition()
|
||||
if position.isGreaterThan(eofPosition)
|
||||
eofPosition
|
||||
else
|
||||
row = Math.max(position.row, 0)
|
||||
column = Math.max(position.column, 0)
|
||||
column = Math.min(@lineLengthForRow(row), column)
|
||||
new Point(row, column)
|
||||
|
||||
clipRange: (range) ->
|
||||
range = Range.fromObject(range)
|
||||
|
||||
Reference in New Issue
Block a user