Marker::copy question


#1

Marker::copy is here … https://github.com/atom/atom/blob/v0.184.0/src/marker.coffee#L85.

I’m trying to clone a marker and even though I’m looking at the code and docs I can’t figure out how to do this. What are the properties that it wants as an arg? If I call copy with no properties it returns null. Is this not a clone operation?


#2

Yep, it looks like there’s a problem with this method, whatever property I pass the result is always undefined and no markers are created. However I succeed to copy a buffer marker based on the example I found in the buffer marker’s spec:

> m.copy({invalidate: 'never'})
undefined
> m.bufferMarker.copy({invalidate: 'never'})
Marker {manager: Object, id: 675, range: Range, tailed: true, reversed: false…}
m.bufferMarker.copy()
Marker {manager: Object, id: 676, range: Range, tailed: true, reversed: false…}

Logically, if I understand the ::copy code, it should create a new marker with the same properties as the original except for the one you redefine in the argument (hence the properties argument). But the code in the atom marker (the display buffer’s marker) seems to be broken.


#3

I added atom/atom issue https://github.com/atom/atom/issues/5789.


#4

I did that, got a marker, and with my bad luck I can’t decorate it, Somewhere in the buffer or editor list of markers that marker doesn’t exist. I’m chasing the problem in core now.

Edit: I realized that it would be much easier to just copy it myself, which I will do.