I develop a package that highlights colors by scanning the buffer and creating markers for each colors found and I encounter a strange behavior since version 0.68 regarding buffer's markers and reload/restart.
I scan the buffer to find colors using a regexp, then I create a marker with some custom properties such the matching string and the css representation of the color. I try to take care of existing markers and only create new ones when needed, but it seems that after a first serialization of the buffer, some markers aren't properly restored, the marker doesn't hold the custom properties, not even the native one, I set a creation (such invalidation or persistence), BTW, setting persistent: false doesn't prevent the marker from being persisted.
The marker management is handled here : https://github.com/abe33/atom-color-highlight/blob/frozen_marker_example/lib/atom-color-highlight-model.coffee#L48
I log during my model creation a property I create on markers here: https://github.com/abe33/atom-color-highlight/blob/frozen_marker_example/lib/atom-color-highlight-model.coffee#L16
On the first run after clearing the storage files I get :
[undefined] atom-color-highlight-model.coffee:17
1
No markers created, all is good.
Then I reload :
[undefined, "#F00", "#FF0000", "rgb(255, 0, 0)", "rgb(100%, 0%, 0%)", "rgba(255, 0, 0, 0.5)", "hsl(0, 100%, 50%)", "hsl(120, 100%, 50%)", "hsl(120, 100%, 25%)", "hsl(120, 100%, 75%)", "hsl(120, 50%, 50%)", "hsla(120, 100%, 50%, 1)", "hsla(120, 100%, 50%, 0.5)", "hsla(120, 100%, 50%, 0.1)", "#00ff00", "#00ff00", "#00ff00", "0xabcdef", "0x66abcdef", "0x11abcdef", "vec4(0.2, 0.4, 0.5, 1)", "vec4(0.2, 0.4, 0.5, 0.5)", "vec4(0.2, 0.4, 0.5, 0.1)"] atom-color-highlight-model.coffee:17
23
No problem here neither, the markers were properly restored with their custom properties.
Then I reload again:
[undefined, "#F00", "#FF0000", "rgb(255, 0, 0)", "rgb(100%, 0%, 0%)", "rgba(255, 0, 0, 0.5)", "hsl(0, 100%, 50%)", "hsl(120, 100%, 50%)", "hsl(120, 100%, 25%)", undefined, undefined, undefined, "hsla(120, 100%, 50%, 0.5)", "hsla(120, 100%, 50%, 0.1)", "#00ff00", "#00ff00", "#00ff00", "0xabcdef", "0x66abcdef", "0x11abcdef", "vec4(0.2, 0.4, 0.5, 1)", "vec4(0.2, 0.4, 0.5, 0.5)", "vec4(0.2, 0.4, 0.5, 0.1)"] atom-color-highlight-model.coffee:17
23
As you can see here, three markers had lost their properties, always the same three markers each time I clear the storage. And, if I continue to reload and reload again, it start to get weirder. Sometimes more markers loses their state, but one reload later they have it again, or it's some other markers that have lost it, etc...
Do you have any clue on what's going on ?
Is it something in the way I create/manage the markers ?
In that case, why, when setting the persistent attribute to false, the markers are stille serialized ? Did I miss the point of the persistent attribute ?