-
Notifications
You must be signed in to change notification settings - Fork 199
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
Broken formatting on Razor (cshtml) files with LF EOL (vscode) #4349
Comments
@davidwengier From your investigations in our formatting area did anything jump out to you as concerning in regards to EOL handling? |
I didn't look at that specifically (yet?) but I did see some cases where new lines were added around C# blocks within razor directives, so if the parsing is choking on newlines and producing multiple code blocks or something I could see this happening. Would have to dig in to be sure. |
Ahhh interesting, in the situations where we were adding newlines were those added newlines via |
Not sure, but it was the Roslyn C# formatter adding the new lines, not Razor tooling by the look of things. |
😲 |
Still testing... Looks like it's specific to Windows/LF combination. |
Does this mean that if I configure VS Code to force everything to CRLF line endings the problem will go away? |
If you're on Windows yes. Gist is the whole stack does a lot of |
To be specific, even if I don't set a global
Haven't tried but I'm guessing it's not specific to VSCode (OmniSharp and others are also used on Vim, for example). |
File EOL isn't an awful idea but we typically stray away from it only because it's a little less defined what to do in mixed newline cases. Not really an excuse on our part though because obv there's ways around that. Just work to be done 😄 |
The cynic in my calls this IWOMP, something of which most of us are guilty.
(It Works on my Platform)
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
From: N. Taylor ***@***.***>
Sent: Saturday, 24 April 2021 8:54 AM
To: ***@***.***>
Cc: Peter ***@***.***>; ***@***.***>
Subject: Re: [dotnet/aspnetcore] Broken formatting on Razor (cshtml) files with LF EOL (vscode) (#31937)
Haven't tried but I'm guessing it's not specific to VSCode (OmniSharp and others are also used on Vim, for example).
So, maybe a solution which detects file EOL would be better. Just a suggestion, don't know how hard it would be.
File EOL isn't an awful idea but we typically stray away from it only because it's a little less defined what to do in mixed newline cases. Not really an excuse on our part though because obv there's ways around that. Just work to be done 😄
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<https://github.com/dotnet/aspnetcore/issues/31937#issuecomment-825982008>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABJ6QOCDMZE2RLTX5JXEIULTKH3C3ANCNFSM43GLA6QA>.
|
Tried again with a "clean" environment (just C# extension, no user settings, nothing more than the repro repo, deleted user
I understand, that's kind of an issue in some edge (I mean, not so infrequent) cases, and would bring confusion. |
After setting Format #1
Format #2
Format #3
|
Thanks for the traces @bryanjhv! Ya I validated that things didn't break down for normal crlf cases which thankfully they don't; however, was definitely able to reproduce after changing the file's crlf -> lf. |
Another report: dotnet/vscode-csharp#5327 |
Describe the bug
Razor (cshtml) file formatting breaks in a very strange way when using LF end of lines.
It doesn't happen if file EOL is CRLF. It's independent of BOM-encoded file (tested this).
To Reproduce
Repository: https://github.com/bryanjhv/aspnet-vscode-issues
(including the steps above and some extra files in the GIF below)
webapp
project usingdotnet new
..cshtml
file with Razor expressions (Index.cshtml
, etc).Exceptions (if any)
None.
Further technical details
ASP.NET Core version: 5.0.5
Include the output of
dotnet --info
The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
Additional notes
Migrated from dotnet/vscode-csharp#4503 as requested.
The text was updated successfully, but these errors were encountered: