From 0a23a219534327b60736dcaa0eb53f15fae8fbfb Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Sat, 14 Mar 2015 09:48:19 +0100 Subject: [PATCH] :art: Get rid of goalBufferRange --- spec/text-editor-spec.coffee | 4 ++-- src/selection.coffee | 22 ++++++++++------------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index fddaf573d..6154af055 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -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, 5]]]) - expect(editor.getSelectedBufferRanges()).toEqual [[[2, 2], [5, 5]]] + editor.setSelectedBufferRanges([[[2, 2], [3, 3]], [[3, 0], [5, 4]]]) + expect(editor.getSelectedBufferRanges()).toEqual [[[2, 2], [5, 4]]] it "does not merge non-empty adjacent selections", -> editor.setSelectedBufferRanges([[[2, 2], [3, 3]], [[3, 3], [5, 5]]]) diff --git a/src/selection.coffee b/src/selection.coffee index 30a64d873..d4538f9dc 100644 --- a/src/selection.coffee +++ b/src/selection.coffee @@ -183,7 +183,7 @@ class Selection extends Model # Public: Clears the selection, moving the marker to the head. clear: -> - @marker.setProperties(goalBufferRange: null, goalScreenRange: null) + @marker.setProperties(goalScreenRange: null) @marker.clearTail() unless @retainSelection @finalize() @@ -695,15 +695,17 @@ class Selection extends Model # the given selection. # # * `otherSelection` A {Selection} to merge with. - # * `options` (optional) {Object} options matching those found in {::setBufferRange}. + # * `options` (optional) {Object} options matching those found in {::setScreenRange}. merge: (otherSelection, options) -> - myGoalBufferRange = @getGoalBufferRange() - otherGoalBufferRange = otherSelection.getGoalBufferRange() - if myGoalBufferRange? and otherGoalBufferRange? - options.goalBufferRange = myGoalBufferRange.union(otherGoalBufferRange) + myGoalScreenRange = @getGoalScreenRange() + otherGoalScreenRange = otherSelection.getGoalScreenRange() + + if myGoalScreenRange? and otherGoalScreenRange? + options.goalScreenRange = myGoalScreenRange.union(otherGoalScreenRange) else - options.goalBufferRange = myGoalBufferRange ? otherGoalBufferRange - @setBufferRange(@getBufferRange().union(otherSelection.getBufferRange()), options) + options.goalScreenRange = myGoalScreenRange ? otherGoalScreenRange + + @setScreenRange(@getScreenRange().union(otherSelection.getScreenRange()), options) otherSelection.destroy() ### @@ -764,10 +766,6 @@ class Selection extends Model plantTail: -> @marker.plantTail() - getGoalBufferRange: -> - if goalBufferRange = @marker.getProperties().goalBufferRange - Range.fromObject(goalBufferRange) - getGoalScreenRange: -> if goalScreenRange = @marker.getProperties().goalScreenRange Range.fromObject(goalScreenRange)