mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
Add ability to copy display buffer markers
This commit is contained in:
parent
c54bb792b2
commit
8b53b4d749
@ -841,3 +841,15 @@ describe "DisplayBuffer", ->
|
||||
marker2.on 'destroyed', destroyedHandler
|
||||
buffer.getMarker(marker2.id).destroy()
|
||||
expect(destroyedHandler).toHaveBeenCalled()
|
||||
|
||||
describe "DisplayBufferMarker.copy(attributes)", ->
|
||||
it "creates a copy of the marker with the given attributes merged in", ->
|
||||
initialMarkerCount = displayBuffer.getMarkerCount()
|
||||
marker1 = displayBuffer.markScreenRange([[5, 4], [5, 10]], a: 1, b: 2)
|
||||
expect(displayBuffer.getMarkerCount()).toBe initialMarkerCount + 1
|
||||
|
||||
marker2 = marker1.copy(b: 3)
|
||||
expect(marker2.getBufferRange()).toEqual marker1.getBufferRange()
|
||||
expect(displayBuffer.getMarkerCount()).toBe initialMarkerCount + 2
|
||||
expect(marker1.getAttributes()).toEqual a: 1, b: 2, invalidation: 'overlap'
|
||||
expect(marker2.getAttributes()).toEqual a: 1, b: 3, invalidation: 'overlap'
|
||||
|
@ -27,6 +27,9 @@ class DisplayBufferMarker
|
||||
|
||||
### Public ###
|
||||
|
||||
copy: (attributes) ->
|
||||
@displayBuffer.getMarker(@bufferMarker.copy(attributes).id)
|
||||
|
||||
# Gets the screen range of the display marker.
|
||||
#
|
||||
# Returns a {Range}.
|
||||
@ -119,6 +122,9 @@ class DisplayBufferMarker
|
||||
clearTail: ->
|
||||
@bufferMarker.clearTail()
|
||||
|
||||
hasTail: ->
|
||||
@bufferMarker.hasTail()
|
||||
|
||||
# Returns whether the head precedes the tail in the buffer
|
||||
isReversed: ->
|
||||
@bufferMarker.isReversed()
|
||||
@ -146,6 +152,13 @@ class DisplayBufferMarker
|
||||
@bufferMarker.destroy()
|
||||
@unsubscribe()
|
||||
|
||||
isEqual: (other) ->
|
||||
return false unless other instanceof @constructor
|
||||
@getBufferRange().isEqual(other.getBufferRange()) and
|
||||
@isReversed() is other.isReversed() and
|
||||
@hasTail() is other.hasTail() and
|
||||
_.isEqual(@getAttributes(), other.getAttributes())
|
||||
|
||||
# Returns a {String} representation of the marker
|
||||
inspect: ->
|
||||
"DisplayBufferMarker(id: #{@id}, bufferRange: #{@getBufferRange().inspect()})"
|
||||
|
2
vendor/telepath
vendored
2
vendor/telepath
vendored
@ -1 +1 @@
|
||||
Subproject commit 93c2eff34a3600e0f6c8ea73f7ae01f1f713559d
|
||||
Subproject commit 8cc54e7038a474e3c24940f4895e62b278de8a26
|
Loading…
Reference in New Issue
Block a user