-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Zen Coding not working with cshtml and razor files #14
Comments
I'm having the same issue as well. Any luck yet? |
Is there any fix for this yet? I've had to go from VSCode to VS19 for work purposes. Hard to live without emmet. This extension seems like it would do the trick for me. |
@Hrolgar Yes actually. In my case it was the experimental Razor editor that was causing the problem, so if you have that on, try turning it off, restart VS and see if that fixes it. |
@TheBinaryGuy that did the trick! |
@Hrolgar No worries, glad it helped. 👍 |
Works for me as well. What features are we missing by turning that experimental editor off? |
@dealdiane I haven't looked into the new editor as much, I only occasionally use Razor nowadays. But here's a blog post from Microsoft if you want to read more about it: https://devblogs.microsoft.com/aspnet/improvements-to-the-new-razor-editor-in-visual-studio/ |
I have it turned off already but it still doesn't work. Edit: |
Also not working in VS2022 (Preview 7.0), even if the language server option is enabled. Seems to work for pure html files sometimes, but also krasches VS totally sometimes. |
@johandanforth what file extension do you expect it to work on that it doesn't? |
Hej @madskristensen . I tried it on a .cshtml file in the ~/Views/Home/ directory of a vanilla .net 6 MVC project. Nothing happens. Also tried "tabbing" inside and outside div elements. Nothing. Then I created a new .html file, and there it worked. I tried to enable the experimental setting for html/css language service, but there was no change. But after enabling that option, VS2022 froze and crashed when I tried a simple "div-tab" in the html-file. Actually something is not fully alright with the extension, Vs freeze/die/restart a couple of times now that I try it some more. I've just forked the code and trying to figure out what's happening with the razor pages not working. |
@madskristensen I got a little longer. I went into tools->options->text editor->Html->Advanced and selected to "Use legacy Razor editor for ASP.NET Core" and restarted. Now ZenCoding kicks in, expands a simple "div" or whatever, but then it crashes, every time (se uploaded images). When using the "new" razor editor (whatever that is), it seems it is of another ContentType than "HTMLX", right? I don't know anything about these things really, but to create a IVsTextViewCreationListener you have to specify the ContenType for the specific kind of "page editor" with something like: [Export(typeof(IVsTextViewCreationListener))]
[ContentType("HTML")]
[ContentType("HTMLX")]
[TextViewRole(PredefinedTextViewRoles.Document)]
public class CommandRegistration : IVsTextViewCreationListener
{
//... and so on
} but the ExpandCommand in ZenCodingVS is never executing for razor pages in ASP.NET Core in VS2022. |
Adding the "RAZOR" content type to the namespace ZenCodingVS
{
[Export(typeof(IVsTextViewCreationListener))]
[ContentType("HTML")]
[ContentType("HTMLX")]
[ContentType("RAZOR")]
[TextViewRole(PredefinedTextViewRoles.Document)]
public class CommandRegistration : IVsTextViewCreationListener
{
[Import]
public IVsEditorAdaptersFactoryService EditorAdaptersFactoryService { get; set; } |
I ran devenv.exe with logging, and got an activity log for you @madskristensen if it may help you. |
Installed product versions
Description
When using a cshtml or razor file TAB Expansion does not work.
Steps to recreate
Create either a cshtml or razor file.
Create some standard HTML markup
Enter any standard appreviation i.e div.row then press tab.
Current behavior
The cursor just tabs across the page
Expected behavior
Expand text as in a regular html page.
The text was updated successfully, but these errors were encountered: