Maintain selection directionality when merging selections with keyboard

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-03-27 11:26:36 -07:00
parent 81869ebf59
commit e62e062f9b
4 changed files with 23 additions and 7 deletions

View File

@@ -49,11 +49,11 @@ class CompositeSeleciton
selectLeft: ->
selection.selectLeft() for selection in @getSelections()
@mergeIntersectingSelections()
@mergeIntersectingSelections reverse: true
selectUp: ->
selection.selectUp() for selection in @getSelections()
@mergeIntersectingSelections()
@mergeIntersectingSelections reverse: true
selectDown: ->
selection.selectDown() for selection in @getSelections()
@@ -71,14 +71,14 @@ class CompositeSeleciton
lastSelection: ->
_.last(@selections)
mergeIntersectingSelections: ->
mergeIntersectingSelections: (options) ->
for selection in @getSelections()
otherSelections = @getSelections()
_.remove(otherSelections, selection)
for otherSelection in otherSelections
if selection.intersectsWith(otherSelection)
selection.merge(otherSelection)
@mergeIntersectingSelections()
selection.merge(otherSelection, options)
@mergeIntersectingSelections(options)
return
modifySelectedText: (fn) ->

View File

@@ -139,11 +139,14 @@ class Selection extends View
isEmpty: ->
@getBufferRange().isEmpty()
isReversed: ->
@cursor.getBufferPosition().isLessThan(@anchorBufferPosition)
intersectsWith: (otherSelection) ->
@getScreenRange().intersectsWith(otherSelection.getScreenRange())
merge: (otherSelection) ->
@setScreenRange(@getScreenRange().union(otherSelection.getScreenRange()))
merge: (otherSelection, options) ->
@setScreenRange(@getScreenRange().union(otherSelection.getScreenRange()), options)
otherSelection.remove()
remove: ->