mirror of
https://github.com/atom/atom.git
synced 2026-02-15 09:05:58 -05:00
Return existing selections from addSelection()
Previously if a selection was added and then merged away the selection-added event would still fire even though the selection was already destroyed. Now the existing selection that intersects with the range is returned when the merge destroys the new selection. Closes #374
This commit is contained in:
@@ -584,9 +584,15 @@ class EditSession
|
||||
cursor = @addCursor(marker)
|
||||
selection = new Selection({editSession: this, marker, cursor})
|
||||
@selections.push(selection)
|
||||
selectionBufferRange = selection.getBufferRange()
|
||||
@mergeIntersectingSelections()
|
||||
@trigger 'selection-added', selection
|
||||
selection
|
||||
if selection.destroyed
|
||||
for selection in @getSelections()
|
||||
if selection.intersectsBufferRange(selectionBufferRange)
|
||||
return selection
|
||||
else
|
||||
@trigger 'selection-added', selection
|
||||
selection
|
||||
|
||||
addSelectionForBufferRange: (bufferRange, options={}) ->
|
||||
options = _.defaults({invalidationStrategy: 'never'}, options)
|
||||
|
||||
Reference in New Issue
Block a user