Use buffer ranges when merging selections

This commit is contained in:
Antonio Scandurra 2015-03-14 10:05:04 +01:00
parent 0a23a21953
commit 6633c90af8
2 changed files with 4 additions and 4 deletions

View File

@ -1456,8 +1456,8 @@ describe "TextEditor", ->
expect(editor.getSelectedBufferRanges()).toEqual [[[5, 5], [6, 6]]]
it "merges intersecting selections", ->
editor.setSelectedBufferRanges([[[2, 2], [3, 3]], [[3, 0], [5, 4]]])
expect(editor.getSelectedBufferRanges()).toEqual [[[2, 2], [5, 4]]]
editor.setSelectedBufferRanges([[[2, 2], [3, 3]], [[3, 0], [5, 5]]])
expect(editor.getSelectedBufferRanges()).toEqual [[[2, 2], [5, 5]]]
it "does not merge non-empty adjacent selections", ->
editor.setSelectedBufferRanges([[[2, 2], [3, 3]], [[3, 3], [5, 5]]])

View File

@ -695,7 +695,7 @@ class Selection extends Model
# the given selection.
#
# * `otherSelection` A {Selection} to merge with.
# * `options` (optional) {Object} options matching those found in {::setScreenRange}.
# * `options` (optional) {Object} options matching those found in {::setBufferRange}.
merge: (otherSelection, options) ->
myGoalScreenRange = @getGoalScreenRange()
otherGoalScreenRange = otherSelection.getGoalScreenRange()
@ -705,7 +705,7 @@ class Selection extends Model
else
options.goalScreenRange = myGoalScreenRange ? otherGoalScreenRange
@setScreenRange(@getScreenRange().union(otherSelection.getScreenRange()), options)
@setBufferRange(@getBufferRange().union(otherSelection.getBufferRange()), options)
otherSelection.destroy()
###