From 9c4478302ea9bf00662cc0c7e35abcbeb6e6daec Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Sun, 21 Jul 2013 17:49:15 -0600 Subject: [PATCH] Translate attribute names in DisplayBufferMarker.matchesAttributes --- src/app/display-buffer-marker.coffee | 19 ++++++++++++++++++- src/app/display-buffer.coffee | 8 ++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/app/display-buffer-marker.coffee b/src/app/display-buffer-marker.coffee index 92d389ccb..831621c0b 100644 --- a/src/app/display-buffer-marker.coffee +++ b/src/app/display-buffer-marker.coffee @@ -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()})" diff --git a/src/app/display-buffer.coffee b/src/app/display-buffer.coffee index 5742c926f..bc5c4c10b 100644 --- a/src/app/display-buffer.coffee +++ b/src/app/display-buffer.coffee @@ -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]