-
Notifications
You must be signed in to change notification settings - Fork 232
Emit the start of multiline implicit expressions the same as explicit… #12624
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
Emit the start of multiline implicit expressions the same as explicit… #12624
Conversation
| } | ||
| </div> | ||
| """, | ||
| expected: """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a lot of cases, formatting is not just about putting things in the right place, but also not moving things if they're already in the right spot. In this case, for object initializers, Roslyn doesn't touch them at all, and so the tests verify that we correctly honour that. The old formatting engine had a bad habit of constantly indenting these sorts of things, every time the formatter ran.
...eAnalysis.Razor.Workspaces/Formatting/Passes/CSharpFormattingPass.CSharpDocumentGenerator.cs
Outdated
Show resolved
Hide resolved
| if (offsetFromEnd == 0) | ||
| { | ||
| // If we're not doing any extra emitting of our own, then we can safely check for newlines | ||
| return CreateLineInfo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Importantly, it can't specify a formattedLength, or the check for new lines wouldn't work.
ToddGrun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
…xImplicitExpressionFormatting
...st/Microsoft.AspNetCore.Razor.LanguageServer.Test/Formatting_NetFx/DocumentFormattingTest.cs
Outdated
Show resolved
Hide resolved
…Formatting_NetFx/DocumentFormattingTest.cs
b326574
into
dev/dawengie/LetsDoHtmlFormatting
Fixes #12622 plus a few others from #12554
Fixes #12631
We already did most of this, just for explicit expressions (ie
@( ... )) so this brings it to implicit expressions too (ie@ ...) when they're multiline. We also used to emit a/* */at the end of the first line, in case there was some non-C# content on the line, and now we check for it so that we can handle Roslyn moving an open brace, or anything else really.