Hi, first a big thanks to you guys for such a great library !
I have a problem when I use multiline function arguments that contains objects:
// This is working OK for me and it is very readable
myFunc('myString',
myFunc2(),
andSoOn());
But when I try:
// This is working OK for me and it is very readable
myFunc('myString',
{ myProp: true }, // I have just insterted this object
andSoOn());
All is reformatted in one line...
myFunc('myString', { myProp: true }, andSoOn());
I am pretty sure it has to do with { "brace_style": "preserve-inline" } rule.
OS: Linux Mint
code Editor: VSCode
Example:
{
"editor": {
"formatOnSave": true
},
"brace_style": "collapse,preserve-inline"
}
Thank you again ;)
It is the collapse
setting that is pulling the open-curly brace back to the previous line.
But it could be argued that preserve-inline
should override that. The hard part is that beautifier can't tell if the block will be inline until it reaches the end of it. That is difficult in the current design.
Ok, I have tried with config:
{
"brace_style": "none,preserve-inline"
}
And the result is the same...also I think this happen only in function params context, all others cases are ok, hope I have some time to check it out.
Hi, for those looking for a solution, here is a workaround:
myFunc( //
{ myProp: true }, //
{ myProp: true }, //
{ myProp: true });
When I put empty comment it wont reformat to one line. At least on VScode. It doesn't render less lisible and is easily removable projectwide with a search and replace (//\n
)
Hope it can help...
@sebRomeo
Ouch. I'm glad you found a work around but that is a painful work around.
Just to be clear "none,preserve-inline"
should work so I'm changing this to bug.