Home Download Buy Blog Forum Support

ST3 Default theme is has subtle syntax error

ST3 Default theme is has subtle syntax error

Postby Steve.Meida.King on Fri Feb 01, 2013 9:14 pm

FYI, the Default theme in ST3 (build 3009) contains a syntax error. I found this when I was trying to modify a copy of it and couldn't figure out
why some changes weren't getting applied. Down around line 308:

Code: Select all
    {
        "class": "panel_close_button",
        "attributes": ["hover"],
        "layer0.opacity": 0.0,
        "layer1.opacity": 1.0,
    },


The last line in the block ("layer1.opacity") has a trailing comma, which is invalid JSON. Took me a helluva long time to find this!
Steve.Meida.King
 
Posts: 5
Joined: Mon Aug 13, 2012 1:40 pm

Re: ST3 Default theme is has subtle syntax error

Postby jps on Sat Feb 02, 2013 1:20 am

Trailing commas are allowed in Sublime Text 3.

The rationale being that we've already departed from the JSON spec in allowing comments, so there's little harm in being friendly about trailing commas too.
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: ST3 Default theme is has subtle syntax error

Postby FichteFoll on Sat Feb 02, 2013 2:33 am

That would issue a challange to editing these JSON files plugin-wise. I made up the comments with some regexp that just strips them but trailing commas would be a pita. Well, I can just mark them as parse errors and let the user take care of them but this does not feel like a step to be taken even. Comments are a thing that JSON really is missing when used as a data structure where you want to comment things but trailing commas is just a hack, even though this is probably the most common error message when parsing key bindings fails.
FichteFoll
 
Posts: 377
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: ST3 Default theme is has subtle syntax error

Postby Steve.Meida.King on Thu Feb 07, 2013 10:27 pm

I could swear that the trailing comma was causing some kind of real problem with my theme, which removing it fixed. However adding it back isn't having any visible effect (even after restarting ST3) so maybe I was hallucinating.

I have mixed feelings about ST3 supporting non-standard JSON extensions. On the one hand, I think the JSON spec is really, really boneheaded for not allowing both comments and superfluous trailing commas in the first place. It's a major pain in the butt that it doesn't. On the other hand it means that ST3 config files can't be viewed or modified with tools that don't also support the extensions. (I actually found this because I was frustrated by my theme not working and I wanted to compare it against the built-in theme element-by-element. I wrote a Python script to do so using the standard json module, which of course choked.) Comments aren't too bad to deal with; a simple regex will strip them. Trailing commas are a bit more difficult to clean out before feeding the file to an external tool.
Steve.Meida.King
 
Posts: 5
Joined: Mon Aug 13, 2012 1:40 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 26 guests