-
Notifications
You must be signed in to change notification settings - Fork 510
Code formatting should place cuddled else on new line when openBraceOnSameLine is false #508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@kapilmb looks like a minor bug in the brace formatting rule |
P.S.: my vote is to not add the Just do full Allman style for |
Uh, if As long as I can get the formatter to format to: if ($true) {
...
}
else {
...
} I'll be happy. :-) |
@rkeithhill With PowerShell/PSScriptAnalyzer#713 checkin, the codeformatter will allow only the following options Style 1
if (...) {
...
}
else {
...
} Style 2
if (...)
{
...
}
else
{
...
} Style 3
if (...) {...} else {...} |
And the new |
@daviwil We haven't exposed that switch via codeformatter - Should we expose that here? Then it would look something like this: '"powershell.codeFormatting.newLineAfterCloseBrace": true` |
Yep, definitely. |
PR #512 adds the |
This is a travesty 😜 if (...) {
...
}
else {
...
} You're choosing "Stroustrup" (style one) over the One True Brace Style? With "cuddled else" like the OTBS, you can safely insert a line (even a blank line) anywhere you like without breaking things. Why push Stroustrup? |
@Jaykul What do you think this is - JavaScript? :-) Picking a default brace style is sort of a no-win situation. I "don't believe sermons, fairy tales or stories about a OTBS" (name that movie). :-) I think the best that can be done is provide settings to allow folks to configure brace style to their own taste. They can configure that setting both per user and per workspace. With that in mind, maybe we need a |
How can I get stroustrup style for my if else statement blocks, I'm going crazy here. |
But before I go too far in assuming what you mean, can you give an example of what you're looking for? |
@daviwil http://eslint.org/docs/rules/brace-style Stroustrup
|
@ctsstc Stroustrup and Allman are the only styles it does right now. Worst of the worst. 😛 I think it works like this: Stroustrup
Allman
|
@ctsstc your desired style is the default in our code formatter. Can you give an example of where our default formatting does not follow that style? |
Oh wow, I've failed, I thought this was the main VSCode Repo; /facepalm... |
No problem! Yeah, that's one of the downsides I suppose, each extension has its own way of configuring code formatting (if it's even supported). You might take a look at the "javascript.format.*" settings and see if you can find the setting you need there. |
In an attempt to conform to the
Allman
style indenting preferred by my team, I setpowershell.codeFormatting.newLineAfterOpenBrace": false
and Format Document converted this:to this:
I don't know what you call that half-cuddled else, but I just call it wrong 😉
If people have set
"powershell.codeFormatting.openBraceOnSameLine": false,
you need to ditch the cuddled else as well -- or add a setting forelseOnSameLine
😀The text was updated successfully, but these errors were encountered: