Skip to content
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

Formatting #4358

Closed
9 of 11 tasks
NTaylorMullen opened this issue Aug 3, 2018 · 54 comments
Closed
9 of 11 tasks

Formatting #4358

NTaylorMullen opened this issue Aug 3, 2018 · 54 comments

Comments

@NTaylorMullen
Copy link
Contributor

Allow Razor documents to be properly formatted.

Bug fixes:

@andrewbusch7
Copy link

Looking forward to this! Currently getting There is no document formatter for 'aspnetcorerazor'-files installed.. I assume this will address the issue, as I do have the C# extension installed.

@NTaylorMullen
Copy link
Contributor Author

Yup!

@matijagrcic
Copy link

Really looking forward to this, any date for it?

Also should aspnetcorerazor be added to the list at https://code.visualstudio.com/docs/languages/identifiers ?

@NTaylorMullen
Copy link
Contributor Author

@matijagrcic I wouldn't add it to that list because the end-goal is once Razor is functioning 100% it would take over the current "Razor" identifier. For now to avoid breaking everyone on the planet we've made a separate content type identifier (aspnetcorerazor)

@matijagrcic
Copy link

Thanks, makes sense, wasn't sure if that was the case.

@enricoreich
Copy link

Is there any progress on this feature?

@NTaylorMullen
Copy link
Contributor Author

@enricoreich Sadly this is planned at least 2 releases out. @danroth27 just pinging you because I noticed all the thumbs up/interest on this one 😄

@Eilon Eilon transferred this issue from aspnet/Razor.VSCode Sep 23, 2019
@Eilon Eilon assigned NTaylorMullen and unassigned NTaylorMullen Sep 23, 2019
@ponchautf
Copy link

Hi,

Did you have any progress to share about this issue progress?

@NTaylorMullen
Copy link
Contributor Author

Did you have any progress to share about this issue progress?

@ponchautf It's definitely one of the most asked for features and it's something we want to accomplish sooner rather than later. That being said we're currently prioritizing other high impact issues such as colorization over this. We're still looking at 2 or so releases out for formatting to land (a few months).

@NTaylorMullen NTaylorMullen removed their assignment Dec 9, 2019
@ajaybhargavb ajaybhargavb self-assigned this Dec 30, 2019
@NTaylorMullen
Copy link
Contributor Author

@ajaybhargavb given we're not going to return to formatting (we got @code formatting done for those watching this comment) till post-build how do you feel about us putting this in the backlog and out of In Progress?

@ajaybhargavb
Copy link
Contributor

Sounds good. We can backlog this until the prerequisites like dotnet/aspnetcore#14286 are handled.

@daniel-scatigno
Copy link

daniel-scatigno commented Apr 17, 2020

Any progress on this? On latest version we have no more "There is no formatter" message but nothing is happening! All my views are a mess, this functionality is a must!

@ajaybhargavb
Copy link
Contributor

@zmp2000, we currently have support for formatting C# code inside the @code/@functions block. HTML formatting is not implemented yet but is definitely one of our top priorities for the near future.

@matijagrcic
Copy link

matijagrcic commented Apr 21, 2020

@ajaybhargavb this year?
Currently this is the sole reason using vs code for core development is unusable. Remember that preview announcement was last year.

Will this new formatting power the VS also?

UPDATE
Used as experimental in VS since the release of Visual Studio 2019 16.7 Preview 4.

@ChristopherHaws
Copy link

Would this also include the ability to customize code style preferences like we currently can with C# in Visual Studio using the options window or .editorconfig file? If not, is there another issue tracking that?

@NTaylorMullen
Copy link
Contributor Author

Would this also include the ability to customize code style preferences like we currently can with C# in Visual Studio using the options window or .editorconfig file? If not, is there another issue tracking that?

What type of code styles are you interested in? I'd imagine C#'s code styles are respected today are they not?

@ChristopherHaws
Copy link

@NTaylorMullen I can think of a few use cases I would use.

  • I would like to be able to have open curly braces on the same line for razor files.
  • In C# we enforce the use of this. but might not want to for razor files since there aren't really constructors in razor files (things are injected using @inject instead of constructors).
  • I would also like a way to enforce the casing of things that are injected using @inject.
  • I personally like putting my @code blocks above the HTML markup, if this could be a preference so that new razor components were created that way would be nice too

I'm sure I could come up with others, but those are some I can think of off the top of my head :)

@NTaylorMullen
Copy link
Contributor Author

Ah I see. So sadly this effort doesn't encompass that 😢

@nextfool
Copy link

nextfool commented Aug 6, 2020

please, is there any progress on this?

@nextfool
Copy link

nextfool commented Aug 6, 2020

please, is there any progress on this?

I would die for having this.

@matijagrcic
Copy link

Still pretty much the same state but the language server is now available in Visual Studio https://devblogs.microsoft.com/aspnet/new-experimental-razor-editor-for-visual-studio/

@krispetkov
Copy link

One more like from me for this feature. Maybe it’s quite annoying for the team but this is the only reason stopping me from using VS Code as a daily driver, as I’m using Razor most of the time.

@daniel-scatigno
Copy link

@nextfool I totally agree, It's a mess, it gives me a headache every day! Specially with Blazor

@nextfool
Copy link

bump

@ponchautf
Copy link

I don't think we should wait anymore for that.
3 year and Vs Code / Omnisharp is still not able to handle razor markups.
formatting is a mess, many many errors, unstable, unusable.

A definitively give up ans switched to JetBrains rider, expensive but not that much regarding the time wasted with Vs code.

Visual studio for Mac is free but it's also the worst IDE I used
Microsoft : please make Visual studio Mac as goo-d as Visual studio Windows (and don't try to rely/stick too much on Mac os UI : make a good IDE, not a good Mac OS IDE).

VS code i a great text editor but not more than that.
Just good enough for Javascript (and even with JS, there sometime stupid issue)

@NTaylorMullen
Copy link
Contributor Author

Hey folks, thought I'd leave a message here and just let you all know that we're hard at work on making Razor formatting reliable, flexible, and more importantly correct 😆! Please bare with us though, it's an incredibly hard area to get right and we want to make sure we're able to deliver a quality experience for everyone to use. Love all the passion though, please keep leaving your suggestions, insight and ideas!

@vchirikov
Copy link

image

@NTaylorMullen
Copy link
Contributor Author

lol ya it's been a while. I'd be super curious as to all of your thoughts on Razor formatting in the latest Visual Studio 2022 builds. We've done loadsssss of work in the area!

/cc @davidwengier

@allisonchou allisonchou transferred this issue from dotnet/aspnetcore Oct 1, 2021
@allisonchou allisonchou added feature request Large improvement request feature-formatting labels Oct 1, 2021
@allisonchou allisonchou added this to the Backlog milestone Oct 1, 2021
@vchirikov
Copy link

If now omnisharp and VS use the same lsp, why don't you update/provide new versions to vscode?
I'd prefer to test it with vs code and it would be nice to have something like latest there..
At the moment razor.format.enable is completely unusable. For example it adds a newline to each line in @code{} (even for empty line) after the format is called.

@nextfool
Copy link

so glad to see they are doing something on this...

@tuespetre
Copy link
Contributor

lol ya it's been a while. I'd be super curious as to all of your thoughts on Razor formatting in the latest Visual Studio 2022 builds. We've done loadsssss of work in the area!

/cc @davidwengier

Since first trying preview 6 (and now using preview 7:)

Before formatting:
image
image

After formatting:
image
image

Kinda drives me crazy, lol

@seanjbsol
Copy link

I've noteid a weird behaviour in my solution when dealing with razor components. When the autoformat runs (which I can't seem to stop) on the insertion of a ';' character, it moves the caret to the end of the opening '@code {' line.

This is a bit disruptive, particularly in a razor component with over 1000 lines of code.

Going into the settings and changing the editor back to the legacy razor editor fixes that, but the code doesn't look anywhere near as pretty. But I may have to do so until the next update lands and I can try this out again.

@seanjbsol
Copy link

I've also managed to repro when I've created a new blazor server app.

@NTaylorMullen
Copy link
Contributor Author

I've noteid a weird behaviour in my solution when dealing with razor components. When the autoformat runs (which I can't seem to stop) on the insertion of a ';' character, it moves the caret to the end of the opening '@code {' line.

This is a bit disruptive, particularly in a razor component with over 1000 lines of code.

Oh definitely! This is probably one of the most disruptive bugs we currently have. I'm sorry you're running into it :(. If it helps we have a fix queued up for 17.0.3 (hopefully mid Dec) and in 17.1-Preview2.

That work was tracked here: https://developercommunity.visualstudio.com/t/In-a-blazor-page-razor-adding-semi-c/1574500

@sanamhub
Copy link

It's pretty sad for developers working on dotnet ecosystem not getting most required features in Microsoft own editor 😃

You would suggest Visual Studio convincing that, It supports almost all the things out of the box!
Yes.. okay I'm using Visual Studio while working on large projects but it gives me trouble if I need to edit some razor file on the go, an I can't use my Flash VSCode for such tasks 😞

@nextfool
Copy link

nextfool commented Feb 8, 2022

bump

@nastro1995
Copy link

nastro1995 commented Sep 8, 2022

Running latest VS Studio 2022 as of 2022/09/08 version 17.3.3.
Still getting strange cshtml formatting with 'ctrl + k' then 'ctrl + d' to format the current document.

when the html is first and the @Sections are placed below the first @section gets formatted correctly, where any that follow or html that follow bellow those @Sections get messed up indentation.

Before updating to 17.3.3 I had 17.1.* and formatting worked fine then

(tried inputting example code to show what i mean but the formatting gets messed up when i try paste in here

Have a epic day!

@adrianwright109
Copy link
Contributor

(tried inputting example code to show what i mean but the formatting gets messed up when i try paste in here

How about adding screenshots instead?

@nastro1995
Copy link

nastro1995 commented Sep 8, 2022

Will do, here they are, what is strange all tags have a closing pair, even in _Layout. and all needed closing braces are there to.

Expected 1
expected 1

Actual 1
wrong-auto-formatting 1

Expected 2
expected 2

Actual 2
wrong-auto-formatting 2

@davidwengier
Copy link
Contributor

Thanks for the info @nastro1995, but I'm going to move your comments to a new issue.

For anyone reading this, its a lot easier for us to track things if you just create new issues for each specific problem, than trying to keep track of huge threads, and the new issues appear in our triage lists etc. so they won't get lost.

Regarding @section directive formatting, there have been a lot of updates since this issue was created (eg #6030 for formatting content, #6402 for formatting Html following a section block, and #6531 for formatting Razor following a section block.

In fact, I'm going to go so far as to say that this issue isn't helping anyone remaining open, and I'm going to close it. If anyone has formatting issues or requests, or indeed any other bug reports or feature requests, please feel free to log new issues for them. Thanks everyone for your participation thus far!

@ghost ghost locked as resolved and limited conversation to collaborators Oct 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests