Closed TyreeJackson closed 8 years ago
Interesting - sounds like auto-indent for {
should run only when the {
is on a newline.
I'm a little nervous about this because we also format if you type the close curly. So even if you have put in whitespace between the property name and then open-curly, then it will get removed. Though maybe this isn't a problem if you have "automatic brace completion" on, as you won't be typing the close curly manually.
Note: looking at our option i don't see anything that controls open-curly:
Perhaps that's the issue?
Looking at our code inside CSharpAutoFormattingService, we just unilaterally format on open curly. We could just make that an user configurable option. @dotnet/mlangide What do you guys think is hte best way to support this scenario?
At least in the old codebase, we never formatted when {
was typed - we would adjust it's indentation when enter was pressed, but nothing else.
I believe that changed because of automatic brace completion. We now format the span of the braces if brace completion is enabled, and that is triggering this behavior. I'm not sure what the right solution is either. I'm not a big fan of adding another option for this though. @balajikris - any ideas?
@heejaechang probably knows. As far as I could go in TFS Roslyn project source, this always existed in one form or another (smart brace indenter, smart token formatter).
I think we do format on "{" do move it to the right place. I think we need to turn off space formatting on "{"
Note, if auto brace complete is turned on we format the line in both Vs2013 and Vs2015 when {
is typed.
To write code as in the screenshot given in the bug description, the user must have had auto brace complete turned off.
So, with auto brace complete turned off, we still seem to format on {
in VS2015, which seems to be the issue.
I had a chat with @heejaechang and it seems like the desired change here could be to not format the spans we do now on {
but only do indenting (if required).
As for,
I'm a little nervous about this because we also format if you type the close curly
That is the case in Vs2013 as well. But that's exposed as an option and the user can turn that off.
How does that sound?
I hope that also clarifies @Pilchie's concerns about possible interferences due to brace completion.
Yes, that sounds right to be @balajikris.
This is still a problem with Visual Studio 2017. I don't know how you can consider this closed! FYI, I'm in TypeScript, and there is simply no option to disable this annoying behavior.
I dont believe typescript uses Roslyn formatter.
@erikeidt Can you please open a new bug over at github.com/microsoft/typescript. please include a repro that demonstrates the problem. Thanks!
Problem
Since upgrading to Visual Studio 2015, every time I type an open curly bracket on a line, Visual Studio removes all extra spacing in between the property name and the bracket even though I've placed the spacing intentionally. I have to hit ctrl-z to undo the formatting and then continue typing. I've checked all throughout the formatting options for the C# editor and I can't find a way to stop this. Is this new behavior intentional? Is there a way to turn it off or avoid it?
In this screenshot, I tabbed over to the same column as the the one the open curly bracket is in on the line before and typed the open curly bracket on the last line. VS removes all but one space between the property name and the bracket.