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

A @foreach within an @if confuses the auto-indentation #6231

Closed
Tragetaschen opened this issue Mar 30, 2022 · 1 comment
Closed

A @foreach within an @if confuses the auto-indentation #6231

Tragetaschen opened this issue Mar 30, 2022 · 1 comment
Labels
✔️ resolution: duplicate This issue or pull request already exists

Comments

@Tragetaschen
Copy link

Describe the bug:
I have an InputSelect within an @if and construct its options by using @foreach.
When I run the Format Document gesture, everything starting with the <option> tag within the @foreach is indented one level too few.

Version used:
VS2022 17.2 Preview 2.0

To reproduce:

@if (flag)
{
    <InputSelect @bind-Value=@value>
        <option value="">null</option>
        @foreach (var item in items)
        {
            <option value=@item>item</option> @* this moves *@
        }
    </InputSelect> @* this moves *@
}

@code {
    bool flag;
    List<string> items = new();
    string value = "";
}

Run the Format Document gesture

Expected behavior:
Nothing should change, the file has the correct indentation.

Actual behavior:
The marked lines are unindented one level:

@if (flag)
{
    <InputSelect @bind-Value=@value>
        <option value="">null</option>
        @foreach (var item in items)
        {
        <option value=@item>item</option> @* this moves *@
        }
</InputSelect> @* this moves *@
}

@code {
    bool flag;
    List<string> items = new();
    string value = "";
}
@ghost ghost added the untriaged label Mar 30, 2022
@davidwengier davidwengier added the ✔️ resolution: duplicate This issue or pull request already exists label Mar 31, 2022
@davidwengier
Copy link
Contributor

Thanks for the report, we are tracking this in #5676

@ghost ghost removed the untriaged label Mar 31, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Apr 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
✔️ resolution: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants