mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Translate attribute names in DisplayBufferMarker.matchesAttributes
This commit is contained in:
@@ -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()})"
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user