tomasr / viasfora

A Visual Studio Extension containing miscellaneous improvements to the editor.
Other
557 stars 91 forks source link

Razor Code Block in ASP Web pages, Rainbow Braces starts at Level 4 #266

Closed f4stunter closed 5 years ago

f4stunter commented 5 years ago

Any Brace in Razor Code Block starts at color level 4. A script block inside of the Razor block will color code correctly. This isn't code breaking, but it doesn't seem to work as expected. I have attached an image demonstrating it working correctly in an HTML script block, and a JavaScript block inside the Razor Code Block but not directly inside the Razor block.

brace color

tomasr commented 5 years ago

This is caused by the way razor works, which is that the entire thing is converted to C# underneath, with the code blocks being essentially "views" on that generated code.

That means that the code blocks don't get parsed on their own, but rather as part of that underlying file, which contains a lot of boilerplate with various nesting levels.

You can easily see what that generated code looks like by examining the buffer layer using the developer extension margin.

f4stunter commented 5 years ago

That's what I thought may be the cause, but wanted to verify. Still beats the stock black brackets. Thanks for putting in the work.