razor icon indicating copy to clipboard operation
razor copied to clipboard

Render fragments formatted to one indent level

Open davidwengier opened this issue 3 years ago • 3 comments

Given the following code:

@code {
    void M()
    {
        RenderFragment rd2 =
    @<InputText Value="123">
        <div>
            <p></p>
        </div>
    </InputText>;
    }
}

No matter what formatting the user uses, we're always formatting the template at one level in. This is consistent across multple formatting operations, so we could be just being opinionated, or taking Html edits without futher processing, so could be by design, but its worth looking into.

The third issue illustracted in this demo: https://youtu.be/nN-V4XYvInM The first 2 are fixed.

Original description:

you'll note 3 problems: 1) when typing `;` after inline `RenderFragment` 2) when hitting enter inside the `new Col { "enter" }` 3) Ctrl+K, Ctrl + D formatting

code for the demo:

@page "/"
@code {
    RenderFragment rf1 = @<text></text>;

    RenderFragment rf2 = @<InputText Value="123"></InputText>;

    List<Col> list = new()
    {
        new Col()
        {
            RenderFunc = str =>
            @<div class="someclass">
                <InputText Value="123"></InputText>
            </div>
        },
        new Col()
        {
            RenderFunc = str =>
            @<ErrorBoundary class="someclass">
                <InputText Value="123"></InputText>
            </ErrorBoundary>
        },
    };

    public class Col
    {
        public Func<string, RenderFragment> RenderFunc { get; set; }
    }
}

Originally posted by @omuleanu in https://github.com/dotnet/razor-tooling/pull/5824#issuecomment-1193082300

davidwengier avatar Jul 23 '22 08:07 davidwengier

I think two of these are already logged, but am not at the computer at the moment, so will find links on Monday.

davidwengier avatar Jul 23 '22 08:07 davidwengier

Item 1 is https://github.com/dotnet/razor-tooling/issues/6191 and is fixed. Item 2 doesn't repro for me in 17.4 preview 1, and I suspect was caused by https://github.com/dotnet/razor-tooling/issues/6191 too

Item 3 is interesting, and I'll update the description to make this issue solely about that, but I wouldn't be surprised if this ends up being by design, and we're just taking the Html formatting as is in this scenario. I've confirmed its definitely not a duplicate of https://github.com/dotnet/razor-tooling/issues/6150 at least, even though its very similar.

davidwengier avatar Aug 12 '22 05:08 davidwengier

Putting this back to triage to discuss further.

davidwengier avatar Aug 12 '22 05:08 davidwengier

Another report: https://developercommunity.visualstudio.com/t/Blazor:-code-section-formatting-is-inco/1681439

davidwengier avatar Sep 02 '22 10:09 davidwengier