Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Support containsScreenPosition/Range in DisplayMarkerLayer.findMarkers
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Sobo committed Mar 10, 2017
1 parent d766103 commit 4f24cae
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/display-marker-layer-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,30 @@ describe "DisplayMarkerLayer", ->
displayLayer.foldBufferRange([[4, 0], [7, 0]])
expect(markerLayer.findMarkers(class: 'a', intersectsScreenRange: [[5, 0], [10, 0]])).toEqual [marker2]

it "allows containsBufferPosition to be specified", ->
marker1 = markerLayer.markBufferRange([[5, 0], [5, 0]], class: 'a')
marker2 = markerLayer.markBufferRange([[8, 0], [8, 0]], class: 'a')
displayLayer.foldBufferRange([[4, 0], [7, 0]])
expect(markerLayer.findMarkers(class: 'a', containsBufferPosition: [8, 0])).toEqual [marker2]

it "allows containsScreenPosition to be specified", ->
marker1 = markerLayer.markBufferRange([[5, 0], [5, 0]], class: 'a')
marker2 = markerLayer.markBufferRange([[8, 0], [8, 0]], class: 'a')
displayLayer.foldBufferRange([[4, 0], [7, 0]])
expect(markerLayer.findMarkers(class: 'a', containsScreenPosition: [5, 0])).toEqual [marker2]

it "allows containsBufferRange to be specified", ->
marker1 = markerLayer.markBufferRange([[5, 0], [5, 10]], class: 'a')
marker2 = markerLayer.markBufferRange([[8, 0], [8, 10]], class: 'a')
displayLayer.foldBufferRange([[4, 0], [7, 0]])
expect(markerLayer.findMarkers(class: 'a', containsBufferRange: [[8, 2], [8, 4]])).toEqual [marker2]

it "allows containsScreenRange to be specified", ->
marker1 = markerLayer.markBufferRange([[5, 0], [5, 10]], class: 'a')
marker2 = markerLayer.markBufferRange([[8, 0], [8, 10]], class: 'a')
displayLayer.foldBufferRange([[4, 0], [7, 0]])
expect(markerLayer.findMarkers(class: 'a', containsScreenRange: [[5, 2], [5, 4]])).toEqual [marker2]

it "works when used from within a Marker.onDidDestroy callback (regression)", ->
displayMarker = markerLayer.markBufferRange([[0, 3], [0, 6]])
displayMarker.onDidDestroy ->
Expand Down
6 changes: 6 additions & 0 deletions src/display-marker-layer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,14 @@ class DisplayMarkerLayer
value = [startBufferRow, endBufferRow]
when 'containsBufferRange'
key = 'containsRange'
when 'containsScreenRange'
key = 'containsRange'
value = @displayLayer.translateScreenRange(value)
when 'containsBufferPosition'
key = 'containsPosition'
when 'containsScreenPosition'
key = 'containsPosition'
value = @displayLayer.translateScreenPosition(value)
when 'containedInBufferRange'
key = 'containedInRange'
when 'containedInScreenRange'
Expand Down

0 comments on commit 4f24cae

Please sign in to comment.