Make BufferMarker return copies of its points so they can't be mutated

This commit is contained in:
Corey Johnson & Nathan Sobo
2013-05-03 17:22:50 -06:00
parent 1b8a8cf939
commit 855f955dec

View File

@@ -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.
#