vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

VS Code not picking up HTML tags after Razor code

Open DanJ210 opened this issue 7 years ago • 14 comments

Issue Type: Bug

I was told by the VS Code GitHub that this is an issue with this extension.

Take a look at the screenshot. You can see <li> tags with a razor action link and then the closing <li> tags after that are not being picked up afterwards.

vs-code_razor

I'm assuming this can easily be reproduced by creating a razor file and then creating an unordered list as shown in the screenshot. This is happening with @Html.ActionLink() as well as @RenderSection and looks like it happens anytime razor code is used at all.

DanJ210 avatar Oct 11 '18 20:10 DanJ210

cc @NTaylorMullen

akshita31 avatar Oct 11 '18 21:10 akshita31

@DanJ210 could you re-upload the screenshot? It's a deadlink on my end (can't see it).

NTaylorMullen avatar Oct 11 '18 21:10 NTaylorMullen

@NTaylorMullen You're right, sorry. I updated above so now it should show up. If you'd like a full screen screenshot I can do that as well. But what you see is happening on every line that there's Razor and in VS Code the file code is selected as Razor.

DanJ210 avatar Oct 12 '18 17:10 DanJ210

Ahhh, thanks for the update and the issue report @DanJ210. This is a frustrating issue but thankfully known! We've started developing the Razor support for VSCode over in https://github.com/aspnet/Razor.VSCode and plan to fix a duplicate issue to this in our Alpha 2 release.

Granted the Alpha 2 release is around 2+ months away so It might be a bit until this bug is fixed 😄

NTaylorMullen avatar Oct 12 '18 17:10 NTaylorMullen

No problem at all.

DanJ210 avatar Oct 12 '18 17:10 DanJ210

Hello, guys

image

Is this the same issue?

timramone avatar Nov 29 '18 09:11 timramone

@timramone You're talking about the red text after the area that you're pointing to? The area you're pointing took looks fine. It's the code after that's being rendered in red, correct?

DanJ210 avatar Nov 29 '18 16:11 DanJ210

No, highlighting here is definitedly incorrect. @( syntax starts C# parsing till next ) symbol, which is in the end of the string. Visual Studio btw has correct highlighting:

image

It understands that string after @ is a C# syntax part.

timramone avatar Nov 29 '18 17:11 timramone

Yup, that's the same as https://github.com/aspnet/Razor.VSCode/issues/75.

Sadly VSCode's primary coloring mechanism lies in a regex grammar. Today the Razor experience uses the one provided out of the box by VSCode. We need to update that grammar to actually reflect the various flavors of a Razor document

NTaylorMullen avatar Nov 29 '18 18:11 NTaylorMullen

This is actually very sad news :( But thanks anyway :)

timramone avatar Nov 29 '18 18:11 timramone

So do you have a suggestion to what I should do, @NTaylorMullen? I've got entire Razor views being rendered in plain colored text so it's harder to follow. Is there a work around I can do? Another file type I should use? Or just go back to Visual Studio until the grammar gets reworked?

DanJ210 avatar Dec 17 '18 17:12 DanJ210

So do you have a suggestion to what I should do, @NTaylorMullen? I've got entire Razor views being rendered in plain colored text so it's harder to follow. Is there a work around I can do? Another file type I should use? Or just go back to Visual Studio until the grammar gets reworked?

Totally understand the frustration. if you wanted you could change the Razor code to do all of the double quoted work inside of an @{...}, save to a variable and then render the variable. Otherwise, your best bet would be to hop over to Visual Studio until we've had a chance to address the grammar issues.

NTaylorMullen avatar Dec 17 '18 18:12 NTaylorMullen

Ok. Well I appreciate the work you all do and I can't wait for a solution.

Thanks for the advice.

DanJ210 avatar Dec 18 '18 17:12 DanJ210

After all this time, is there anything i can do about it? image

ingram10 avatar Jun 17 '22 15:06 ingram10