mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Write DisplayBuffer::findMarkers in terms of TextBuffer::findMarkers
This commit is contained in:
committed by
Nathan Sobo
parent
0e49582616
commit
03712392c9
@@ -157,21 +157,8 @@ class DisplayBufferMarker
|
||||
@bufferMarker.setAttributes(attributes)
|
||||
|
||||
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)
|
||||
attributes = @displayBuffer.translateToStringMarkerAttributes(attributes)
|
||||
@bufferMarker.matchesAttributes(attributes)
|
||||
|
||||
# Destroys the marker
|
||||
destroy: ->
|
||||
|
||||
@@ -509,8 +509,23 @@ class DisplayBuffer
|
||||
#
|
||||
# Returns an {Array} of {DisplayBufferMarker}s
|
||||
findMarkers: (attributes) ->
|
||||
markers = @getMarkers().filter (marker) -> marker.matchesAttributes(attributes)
|
||||
markers.sort (a, b) -> a.compare(b)
|
||||
attributes = @translateToStringMarkerAttributes(attributes)
|
||||
@buffer.findMarkers(attributes).map (stringMarker) => @getMarker(stringMarker.id)
|
||||
|
||||
translateToStringMarkerAttributes: (attributes) ->
|
||||
stringMarkerAttributes = {}
|
||||
for key, value of attributes
|
||||
switch key
|
||||
when 'startBufferRow'
|
||||
key = 'startRow'
|
||||
when 'endBufferRow'
|
||||
key = 'endRow'
|
||||
when 'containsBufferRange'
|
||||
key = 'containsRange'
|
||||
when 'containsBufferPosition'
|
||||
key = 'containsPosition'
|
||||
stringMarkerAttributes[key] = value
|
||||
stringMarkerAttributes
|
||||
|
||||
findFoldMarker: (attributes) ->
|
||||
@findFoldMarkers(attributes)[0]
|
||||
|
||||
Reference in New Issue
Block a user