Use new marker attribute API to store/replicate selection goal ranges

This commit is contained in:
Nathan Sobo
2013-07-20 02:24:35 -07:00
parent c85932d46b
commit 2b7a294cdd
3 changed files with 9 additions and 10 deletions

View File

@@ -144,6 +144,9 @@ class DisplayBufferMarker
getAttributes: ->
@bufferMarker.getAttributes()
setAttributes: (attributes) ->
@bufferMarker.setAttributes(attributes)
matchesAttributes: (attributes) ->
@bufferMarker.matchesAttributes(attributes)

View File

@@ -108,7 +108,7 @@ class Selection
# Clears the selection, moving the marker to move to the head.
clear: ->
@setGoalBufferRange(null)
@marker.setAttributes(goalBufferRange: null)
@marker.clearTail() unless @retainSelection
# Modifies the selection to mark the current word.
@@ -232,9 +232,6 @@ class Selection
getGoalBufferRange: ->
@marker.getAttributes().goalBufferRange
setGoalBufferRange: (goalBufferRange) ->
@marker.getAttributes().goalBufferRange = goalBufferRange
# Moves the selection up one row.
addSelectionAbove: ->
range = (@getGoalBufferRange() ? @getBufferRange()).copy()
@@ -514,14 +511,13 @@ class Selection
# otherSelection - A `Selection` to merge with
# options - A hash of options matching those found in {.setBufferRange}
merge: (otherSelection, options) ->
@setBufferRange(@getBufferRange().union(otherSelection.getBufferRange()), options)
myGoalBufferRange = @getGoalBufferRange()
otherGoalBufferRange = otherSelection.getGoalBufferRange()
if myGoalBufferRange? and otherGoalBufferRange?
@setGoalBufferRange(myGoalBufferRange.union(otherGoalBufferRange))
else if otherGoalBufferRange
@setGoalBufferRange(otherGoalBufferRange)
options.goalBufferRange = myGoalBufferRange.union(otherGoalBufferRange)
else
options.goalBufferRange = myGoalBufferRange ? otherGoalBufferRange
@setBufferRange(@getBufferRange().union(otherSelection.getBufferRange()), options)
otherSelection.destroy()
### Internal ###