Translate attribute names in DisplayBufferMarker.matchesAttributes

This commit is contained in:
Nathan Sobo
2013-07-21 17:49:15 -06:00
parent 28a0bdaf95
commit 9c4478302e
2 changed files with 20 additions and 7 deletions

View File

@@ -148,7 +148,21 @@ class DisplayBufferMarker
@bufferMarker.setAttributes(attributes)
matchesAttributes: (attributes) ->
@bufferMarker.matchesAttributes(attributes)
for key, value of attributes
return false unless @matchesAttribute(key, value)
true
matchesAttribute: (key, value) ->
switch key
when 'startBufferRow'
key = 'startRow'
when 'endBufferRow'
key = 'endRow'
when 'containsBufferRange'
key = 'containsRange'
when 'containsBufferPosition'
key = 'containsPosition'
@bufferMarker.matchesAttribute(key, value)
# Destroys the marker
destroy: ->
@@ -159,6 +173,9 @@ class DisplayBufferMarker
return false unless other instanceof @constructor
@bufferMarker.isEqual(other.bufferMarker)
compare: (other) ->
@bufferMarker.compare(other.bufferMarker)
# Returns a {String} representation of the marker
inspect: ->
"DisplayBufferMarker(id: #{@id}, bufferRange: #{@getBufferRange().inspect()})"

View File

@@ -504,12 +504,8 @@ class DisplayBuffer
#
# Returns an {Array} of {DisplayBufferMarker}s
findMarkers: (attributes) ->
{ startBufferRow, endBufferRow, containsBufferRange } = attributes
attributes.startRow = startBufferRow if startBufferRow?
attributes.endRow = endBufferRow if endBufferRow?
attributes.containsRange = containsBufferRange if containsBufferRange?
attributes = _.omit(attributes, ['startBufferRow', 'endBufferRow', 'containsBufferRange'])
@buffer.findMarkers(attributes).map ({id}) => @getMarker(id)
markers = @getMarkers().filter (marker) -> marker.matchesAttributes(attributes)
markers.sort (a, b) -> a.compare(b)
findFoldMarker: (attributes) ->
@findFoldMarkers(attributes)[0]