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

Razor editor format document indents incorrectly for InputSelect components #5676

Closed
vsfeedback opened this issue Oct 29, 2021 · 12 comments · Fixed by #6245
Closed

Razor editor format document indents incorrectly for InputSelect components #5676

vsfeedback opened this issue Oct 29, 2021 · 12 comments · Fixed by #6245
Assignees
Labels
author: migration bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author bug Something isn't working external Scope involves an area outside of the repo feature-formatting

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


When using Format Document (Ctrl E+D), the resulting format of razor files sometimes produces incorrect indentation. This seems to happen where code switches between markup and code.

In the code in the screenshot for example, there are a couple of inconsistencies.

  1. The braces after the foreach loops get indented differently.
  2. The closing tags of the InputSelects end up with indentations not always matching the opening tag.

The second might issue be related to the first, if for example the formatter wants to have the next line after the closing brace to be two tabs behind the brace. Either way, this is not correct.

In my perfect world, the braces would be indented like in the first foreach loop in the screenshot, with the braces at the same level as the foreach keyword, but with the contents of the loop being indented one step. And of course the closing InputSelect tag should be at the same level as the opening tag.


Original Comments

Feedback Bot on 26/10/2021, 01:02 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

@ghost ghost added untriaged author: migration bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author labels Oct 29, 2021
@davidwengier
Copy link
Contributor

This seems to repro with an InputSelect component. There is one in the eShopOnWeb project if anyone is looking :)

@davidwengier
Copy link
Contributor

This repros it:

<div>
    @if (true)
    {
        <div>
            <InputSelect @bind-Value="_item.CatalogBrandId">
                @if (true)
                {
                    <option>goo</option>
                }
            </InputSelect>
        </div>
    }
</div>

Without the outer if, or without the @bind-value, it doesn't repro

@davidwengier
Copy link
Contributor

Looks like this is caused by a bug in the Roslyn C# formatter: dotnet/roslyn#57465

@NTaylorMullen NTaylorMullen added the external Scope involves an area outside of the repo label Nov 4, 2021
@NTaylorMullen NTaylorMullen added this to the 17.1-Preview2 CC:~11/29 milestone Nov 4, 2021
@ghost ghost removed the untriaged label Nov 4, 2021
@NTaylorMullen NTaylorMullen added the bug Something isn't working label Nov 4, 2021
@davidwengier davidwengier modified the milestones: 17.1-Preview3 CC:~1/3, 17.2 Candidates Jan 6, 2022
@jeffpapp

This comment was marked as outdated.

@davidwengier

This comment was marked as outdated.

@davidwengier
Copy link
Contributor

@davidwengier davidwengier changed the title Razor editor format document indents incorrectly Razor editor format document indents incorrectly for InputSelect components Feb 16, 2022
@davidwengier
Copy link
Contributor

@davidwengier
Copy link
Contributor

The Roslyn issue is fixed! Will leave this open until I have been able to verify the fix.

@davidwengier
Copy link
Contributor

Update, this is now blocked by dotnet/roslyn#60437

@jeffpapp

This comment was marked as off-topic.

@davidwengier

This comment was marked as off-topic.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
author: migration bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author bug Something isn't working external Scope involves an area outside of the repo feature-formatting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants