-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Description
I've looked through the issues and found similar posts, but nothing quite like this. I also tried looking at the code itself for a little bit, to see if I could figure out why this happens, but couldn't really get my head around it.
As far as I can tell, the formatter only allows mid-value newlines when they follow commas. This is sensible, but in the case of nested functions specifically, I'd like to be able to insert newlines around parentheses without the formatter eating them; they indicate a boundary just like commas do, after all.
I don't THINK an implementation like this would be disruptive or horribly complex, but I know all too well how famous those last words are.
I'll also note the formatter's addition of two tabs/eight spaces, even though I don't mind it, and wouldn't mind if it kept doing that.
Maybe it's a clue as to why the newlines are consumed/where they are instructed to be.
Input
The code looked like this before beautification:
:root
{
--size: calc(
max(var(--foo),
var(--bar)
) + var(--padding) * 2);
}Expected Output
The code should have looked like this after beautification:
:root
{
--size: calc(
max(var(--foo),
var(--bar)
) + var(--padding) * 2);
}OR
:root
{
--size: calc(
max(var(--foo),
var(--bar)
) + var(--padding) * 2);
}Actual Output
The code actually looked like this after beautification:
:root
{
--size: calc(max(var(--foo),
var(--bar)) + var(--padding) * 2);
}Steps to Reproduce
Environment
(I use VSCode on a Windows 11 machine, and found this repo through investigation along those lines. But taking inspiration from another issue I saw, I reproduced this behavior with the above online tool, for simplicity's sake.)
Settings
(beautifier.io default, save for "brace_style": "expand")
{
"indent_size": "4",
"indent_char": " ",
"max_preserve_newlines": "5",
"preserve_newlines": true,
"keep_array_indentation": false,
"break_chained_methods": false,
"indent_scripts": "normal",
"brace_style": "expand",
"space_before_conditional": true,
"unescape_strings": false,
"jslint_happy": false,
"end_with_newline": false,
"wrap_line_length": "0",
"indent_inner_html": false,
"comma_first": false,
"e4x": false,
"indent_empty_lines": false
}