Open bryanjhv opened 3 years ago
@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.
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 Environment.NewLine
or via a configured newline?
Not sure, but it was the Roslyn C# formatter adding the new lines, not Razor tooling by the look of things.
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. Tried reproducing the issue in a Codespaces VM, and works fine with LF/CRLF. Don't know if the same would happen when testing on a real Linux machine, though.
Still testing... Looks like it's specific to Windows/LF combination. Tried reproducing the issue in a Codespaces VM, and works fine with LF/CRLF.
Does this mean that if I configure VS Code to force everything to CRLF line endings the problem will go away?
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 Environment.Newline
in .NET which doesn't respect the VSCode's newline setting 😄
Does this mean that if I configure VS Code to force everything to CRLF line endings the problem will go away?
To be specific, even if I don't set a global files.eol
setting, but just the file to CRLF, everything is fine.
In the repro repo I'm forcing it to LF via EditorConfig (then uninstalled, discarding issues with other extensions).
Gist is the whole stack does a lot of
Environment.Newline
in .NET which doesn't respect the VSCode's newline setting
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.
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 😄
The cynic in my calls this IWOMP, something of which most of us are guilty. (It Works on my Platform)
Sent from Mailhttps://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 GitHubhttps://github.com/dotnet/aspnetcore/issues/31937#issuecomment-825982008, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABJ6QOCDMZE2RLTX5JXEIULTKH3C3ANCNFSM43GLA6QA.
The cynic in my calls this IWOMP, something of which most of us are guilty.
Tried again with a "clean" environment (just C# extension, no user settings, nothing more than the repro repo, deleted user omnisharp.json
in case Roslynator interfered).
Here's the result (still happening at least for me). One thing to notice is that it takes one save (or a modification as I said at point 5 of my "To Reproduce" steps) to show the issue. Don't know the way VSCode works but it seems it doesn't execute save actions (formatting in this case) on unmodified files (but that's another thing).
we typically stray away from it only because it's a little less defined what to do in mixed newline cases
I understand, that's kind of an issue in some edge (I mean, not so infrequent) cases, and would bring confusion. Some sort of "auto-detect EOL" setting would be useful but, again, that's another thing unrelated to this issue.
After setting razor.trace
to Verbose
in order to have a Razor Log (to provide more information on where the issue would be, if logged), here are the results on three consecutive formatting requests:
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.
Hi to everyone, I've the same problem on my vscode on Mac Os M1. When I save , with the option Format on Save, the html code wrapped with @{} is formatted with bad identation. I hope the bug is as soon as solved. Thanks for your work
Another report: https://github.com/OmniSharp/omnisharp-vscode/issues/5327
Hi to everyone, I've the same problem on my vscode on Mac Os M1. When I save , with the option Format on Save, the html code wrapped with @{} is formatted with bad identation. I hope the bug is as soon as solved. Thanks for your work
Same thing here. Also on a M1 Mac.
same error here with index.razor file
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 https://github.com/OmniSharp/omnisharp-vscode/issues/4503 as requested.