Closed mxr closed 4 months ago
Thanks for reporting. However, this feature works as designed. Although it's not designed particularly well.
The expressionWidth
is only applied when there are no other rules that trigger newlines inside the parenthesis. In the first example PARTITION BY
and ORDER BY
get always formatted on separate lines, no matter the context where they are.
Similarly in the second example the OR
is always put to separate line. I admit that this is unfortunate, but it's a result of the formatter not understanding any context - that is, the main goal of that is to separate the conditions inside FROM
and WHERE
clauses, but the formatter has no idea whether it's formatting text inside WHERE
clause or somewhere else.
This is unlikely to change as it would require a major architectual change and I've opted to instead write another formatting tool rather than attempt to fix this one.
I'm also closing this issue as this isn't really a problem in the VSCode extension itself, but in the underlying SQL formatter library.
Got it. Thanks for the clear response and next steps!
Describe the bug
Hello, thanks for this tool. When I set
SQL-Formatter-VSCode.expressionWidth
the value is not respected and lines are broken prematurelyTo Reproduce
@ext:renesaarsoo.sql-formatter-vsc
Now create a file with the following contents
Change language mode to "Snowflake SQL" or "SQL"
Run the VSCode formatter with ⇧⌥F
Expected behavior
QUALIFY ROW_NUMBER() over ( PARTITION BY id ORDER BY dt desc ) = 1
should stay on one line as the expression between parentheses is < 120 characters. Instead, the expression gets split up over multiple linesScreenshots
n/a
Usage
Snowflake SQL and SQL
1.91.0
My user settings are:
Additional context Another example
Gets broken up into