jcberquist / sublimetext-cfml

CFML (ColdFusion and Lucee) package for Sublime Text
MIT License
115 stars 24 forks source link

after_comma_spacing default should be "spaced" #74

Closed mjhagen closed 6 years ago

mjhagen commented 7 years ago

When I omit after_comma_spacing from any of the top level keys in my own cfml_format.sublime-settings file it defaults to compact, I would think that it would default to the value it has in the package cfml_format.sublime-settings file (which is spaced).

jcberquist commented 7 years ago

The issue here (and I am probably going to say some things here you already know) is that ST merges the default settings with the user settings at the top level, and not recursively. If you leave a key out of a nested object, then that setting will be gone, rather than falling back to the setting in the default settings file. So in the situation you describe the formatting command cannot find the after_comma_spacing setting. Rather than throw an error (maybe that would be better?) I chose to treat it as if you had set it to compact. I checked and I did document the situation in the default settings file as I note there:

// IMPORTANT: it merges at the top key level, and not recursively, so when specifying a
// settings object in your user settings file, you must include all of its properties

and with regard to white space settings when formatting delimited scopes in particular:

// if the `delimited_scopes` command is run, due to how it computes whether to render inline or multiline, the
// whitespace settings cannot be ignored, and anything other than `spaced` will be treated as `compact`

Now I suspect you already knew that, and I get that it might be preferable to fall back to the nested setting in the default settings, so maybe it is worth changing that around. But I do regard the situation of specifying a nested object without specifying all of its keys as "unsupported", so my first preference would be that you include all of the nested object keys. (Particularly since not all of the default white space settings are set the same way.)

mjhagen commented 7 years ago

Yeah, I knew about the nested keys part, this was indeed just about the defaults differing from what they are in the default settings file. Maybe leave this issue as an enhancement request? Otherwise you can close it :)

jcberquist commented 7 years ago

I figured :) I will leave this here for now, because I may go ahead and change them for the sake of consistency.

jcberquist commented 6 years ago

I have (finally) flattened the settings file, so this is no longer an issue.