mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Add startRow and endRow special attributes to TextBuffer.findMarker[s]
This commit is contained in:
@@ -966,6 +966,11 @@ describe 'Buffer', ->
|
||||
it "returns the markers matching the given attributes, sorted by the buffer location and size of their ranges", ->
|
||||
expect(buffer.findMarkers(class: 'a')).toEqual [marker2, marker1, marker3]
|
||||
|
||||
it "allows the startRow and endRow to be specified", ->
|
||||
expect(buffer.findMarkers(class: 'a', startRow: 0)).toEqual [marker2, marker1]
|
||||
expect(buffer.findMarkers(class: 'a', startRow: 0, endRow: 3)).toEqual [marker1]
|
||||
expect(buffer.findMarkers(endRow: 10)).toEqual [marker4]
|
||||
|
||||
describe "marker destruction", ->
|
||||
marker = null
|
||||
|
||||
|
||||
@@ -50,7 +50,13 @@ class BufferMarker
|
||||
# Returns a {Boolean}.
|
||||
matchesAttributes: (queryAttributes) ->
|
||||
for key, value of queryAttributes
|
||||
return false unless _.isEqual(@attributes[key], value)
|
||||
switch key
|
||||
when 'startRow'
|
||||
return false unless @getRange().start.row == value
|
||||
when 'endRow'
|
||||
return false unless @getRange().end.row == value
|
||||
else
|
||||
return false unless _.isEqual(@attributes[key], value)
|
||||
true
|
||||
|
||||
# Public: Identifies if the marker's head position is equal to its tail.
|
||||
|
||||
@@ -434,6 +434,11 @@ class Buffer
|
||||
|
||||
# Public: Finds all markers satisfying the given attributes
|
||||
#
|
||||
# attributes - The attributes against which to compare the markers' attributes
|
||||
# There are some reserved keys that match against derived marker properties:
|
||||
# startRow - The row at which the marker starts
|
||||
# endRow - The row at which the marker ends
|
||||
#
|
||||
# Returns an {Array} of {String} marker-identifiers
|
||||
findMarkers: (attributes) ->
|
||||
markers = @getMarkers().filter (marker) -> marker.matchesAttributes(attributes)
|
||||
|
||||
Reference in New Issue
Block a user