Styles don't apply to view after reload

#1

Hello,
I am developing a package that creates a view which displays some HTML elements. Toggling the view works fine and styles are applied.
When I implement the serialize and deserialize methods and reload atom having the view open using Ctrl+Shift+F5, the view is opened correctly again after the reload but no styles are applied anymore.
Maybe I missed something in the serialization? I really am lost here, I followed the “Active Editor Info” tutorial from the flight manual step by step.

Any help is appreciated

#2

It would be helpful if you posted your package code. Right now, my guess is that you have an activationCommands key in your package.json, which prevents all package code (including styles, snippets, grammars, and so on) from loading until the command has been triggered.

#3

Thanks for your reply. You are correct, my package.json does specify an activationCommands key, you can see the code here: https://github.com/Edgxxar/etch-test
How would I specify an activation on deserialization?

#4

I don’t know for absolute certain, but I don’t think you do. What I think you should do is have deserialize() save the previous state information to a variable but not create a new EtchTestView.

#5

That sounds like the correct approach for the state of the view, but not for the state of the package itself being activated. I want my package to be activated when its deserialize() function is called, but using atom.packages.enablePackage('etch-test'); doesn’t seem to do the trick. Do you know how I can achieve that? Or is it enough to just call the activate() method of the package myself?

#6

If you want the package to be activated automatically, then remove activationCommands from package.json. Right now, the way to activate it is by calling etch-test:toggle, because of that configuration.

#7

that solved my problem entirely, thank you very much :slight_smile: