Replicate the destruction of selections

This commit is contained in:
Ben Ogle & Nathan Sobo
2013-07-17 11:53:39 -07:00
parent 6079dd4ba3
commit bb695ec53f
4 changed files with 13 additions and 12 deletions

View File

@@ -25,6 +25,9 @@ describe "EditSession replication", ->
editSession1.addCursorAtBufferPosition([5, 6])
expect(editSession2.getSelectedBufferRanges()).toEqual editSession1.getSelectedBufferRanges()
editSession1.consolidateSelections()
expect(editSession2.getSelectedBufferRanges()).toEqual editSession1.getSelectedBufferRanges()
it "replicates the scroll position", ->
expect(editSession2.getScrollTop()).toBe editSession1.getScrollTop()
expect(editSession2.getScrollLeft()).toBe editSession1.getScrollLeft()

View File

@@ -35,13 +35,14 @@ class Cursor
@trigger 'moved', movedEvent
@editSession.trigger 'cursor-moved', movedEvent
@marker.on 'destroyed', =>
@destroyed = true
@editSession.removeCursor(this)
@trigger 'destroyed'
@needsAutoscroll = true
destroy: ->
@destroyed = true
@marker.destroy()
@editSession.removeCursor(this)
@trigger 'destroyed'
changePosition: (options, fn) ->
@goalColumn = null

View File

@@ -18,16 +18,13 @@ class Selection
constructor: ({@cursor, @marker, @editSession, @goalBufferRange}) ->
@cursor.selection = this
@marker.on 'changed', => @screenRangeChanged()
@cursor.on 'destroyed.selection', =>
@cursor = null
@destroy()
@marker.on 'destroyed', =>
@destroyed = true
@editSession.removeSelection(this)
@trigger 'destroyed' unless @editSession.destroyed
destroy: ->
return if @destroyed
@destroyed = true
@editSession.removeSelection(this)
@trigger 'destroyed' unless @editSession.destroyed
@cursor?.destroy()
@marker.destroy()
finalize: ->
@initialScreenRange = null unless @initialScreenRange?.isEqual(@getScreenRange())