mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Make BufferMarker return copies of its points so they can't be mutated
This commit is contained in:
@@ -74,19 +74,19 @@ class BufferMarker
|
||||
# Returns a {Range}.
|
||||
getRange: ->
|
||||
if @tailPosition
|
||||
new Range(@tailPosition, @headPosition)
|
||||
new Range(@getTailPosition(), @getHeadPosition())
|
||||
else
|
||||
new Range(@headPosition, @headPosition)
|
||||
new Range(@getHeadPosition(), @getHeadPosition())
|
||||
|
||||
# Public: Retrieves the position of the marker's head.
|
||||
#
|
||||
# Returns a {Point}.
|
||||
getHeadPosition: -> @headPosition
|
||||
getHeadPosition: -> @headPosition?.copy()
|
||||
|
||||
# Public: Retrieves the position of the marker's tail.
|
||||
#
|
||||
# Returns a {Point}.
|
||||
getTailPosition: -> @tailPosition ? @getHeadPosition()
|
||||
getTailPosition: -> @tailPosition?.copy() ? @getHeadPosition()
|
||||
|
||||
# Public: Sets the position of the marker's head.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user