dotnet / razor

Compiler and tooling experience for Razor ASP.NET Core apps in Visual Studio, Visual Studio for Mac, and VS Code.
https://asp.net
MIT License
505 stars 195 forks source link

auto-completing div tags doesn't work properly in nested scenarios #7608

Open vsfeedback opened 2 years ago

vsfeedback commented 2 years ago

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


When working on markup on a razor page in a blazor wasm project the auto-closing of tags does not seem to work properly when inside a @{ } code block. For example, if I am typing markup outside of a code block when I type a

the editor automatically adds the closing
. If I am inside of a code block however the editor does not add the closing tag. Then when I go to add the closing tag myself, the editor changes the closing tag I typed in to an opening tag and then adds a closing tag. See screenshot.


Original Comments

Feedback Bot on 11/18/2021, 09:57 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)

NTaylorMullen commented 2 years ago

Can repro, try typing out the inner divs here:

@if (true)
{
    <div>
        @if (true)
        {
            <div>
                <div></div>
            </div>
        }
    </div>
}
allisonchou commented 2 years ago

Dug into this and I think this is a compiler issue.

For example, take the following code:

@if (true)
{
    <div>
        @if (true)
        {
            <div>
        }
    </div>
}

The compiler associates the inner starting div tag with the closing div tag. I believe instead it should associate the outer starting div tag with the closing div tag.

@NTaylorMullen before I transfer over the issue, does this logic check out?

NTaylorMullen commented 2 years ago

@NTaylorMullen before I transfer over the issue, does this logic check out?

Totally checks out! Transfer away 😄

allisonchou commented 2 years ago

This may be a dupe of dotnet/razor-tooling#7616

allisonchou commented 2 years ago

Another report: https://developercommunity.visualstudio.com/t/Tag-Autocomplete-is-Not-Occurring/1703313

NTaylorMullen commented 2 years ago

Lots of context for this issue is here: https://github.com/dotnet/razor-tooling/issues/7616

joehatescoffee commented 2 years ago

I just recently update to VS 2022 17.2.3 as a suggestion to fix this bug.

The bug is still there.

ghost commented 2 years ago

This bug is present on Microsoft Visual Studio Community 2022 (64-bit) Version 17.2.6.

333fred commented 2 years ago

This bug is unlikely to be fixed soon, as error recovery in the razor compiler is extremely complicated and we need a large amount of work to fix it. Continued comments of where this appears isn't going to push progress. In particular, the example Allison showed at https://github.com/dotnet/razor-tooling/issues/7608 is likely to be near impossible to recover from. Please upvote the original post if you want to express that this is affecting you.

tbasallo commented 2 years ago

@333fred I think the issue with this bug is that people keep posting new issues and they are closed with duplicate and reference some other issue (like dotnet/razor-tooling#7616 , but there are many others). I deal with this all day long making VS so frustrating to use that I am considering another IDE for the first time EVER. Rider being the first one on my list - which is a lot cheaper than VS,

While I understand it's complicated and "computer science is hard" it was the MS team that decided to drop the previous editor and force this one on everyone when it was buggy in preview.

Oninaig commented 1 year ago

Any status update on this issue? Autocompletion of nested div is still broken as of the latest 2023 update.