Anchors are destroyed when encompassed by a buffer change

This commit is contained in:
Nathan Sobo
2012-07-05 14:53:37 -06:00
parent 0043a5045b
commit 60a4f23c50
3 changed files with 33 additions and 3 deletions

View File

@@ -15,6 +15,10 @@ class Anchor
{ oldRange, newRange } = e
position = @getBufferPosition()
if oldRange.containsPoint(position, exclusive: true)
@destroy()
return
if @ignoreEqual
return if position.isLessThanOrEqual(oldRange.end)
else
@@ -62,7 +66,8 @@ class Anchor
@setScreenPosition(screenPosition, bufferChange: options.bufferChange, clip: false, assignBufferPosition: false)
destroy: ->
@off()
@editSession.removeAnchor(this)
@trigger 'destroy'
@off()
_.extend(Anchor.prototype, EventEmitter)

View File

@@ -49,9 +49,12 @@ class Range
else
otherRange.intersectsWith(this)
containsPoint: (point) ->
containsPoint: (point, { exclusive } = {}) ->
point = Point.fromObject(point)
point.isGreaterThanOrEqual(@start) and point.isLessThanOrEqual(@end)
if exclusive
point.isGreaterThan(@start) and point.isLessThan(@end)
else
point.isGreaterThanOrEqual(@start) and point.isLessThanOrEqual(@end)
containsRow: (row) ->
@start.row <= row <= @end.row