madskristensen / VuePack2017

A Visual Studio extension
Other
37 stars 14 forks source link

Switch ComponentType to HTML fixing formatting #3

Closed 9swampy closed 7 years ago

9swampy commented 7 years ago

@madskristensen @jramsay (cc @billti)

Apply fix suggested in Issue #2 to switch ContentType to HTML. Confirmed it fixes Javascript formatting (bracket indentation and highlighting bracket pairs) within Vue SingleFileComponents. Don't see anything broken to date...

madskristensen commented 7 years ago

This is not a good idea. The content type HTML is for the legacy Web Forms editor and doesn't have all the new shiny features of the HTMLX editor. @jramsay, why does it seem to work for Web Forms editor but not for the newer HTML editor?

jramsay commented 7 years ago

@madskristensen : this is the GetHostType check that is currently failing in Roslyn:

if (projectionBuffer.SourceBuffers.Any(b => b.ContentType.IsOfType(HTML) ||
string.Compare(HTMLX, b.ContentType.TypeName, StringComparison.OrdinalIgnoreCase) == 0))
{
return HostType.HTML; }

For .html files the ContentType.TypeName == "htmlx", so the second condition passes. For .vue the TypeName is "Vue" that is why it is failing. There is a PR our on the Roslyn side to change this: https://github.com/dotnet/roslyn/pull/17221/files#diff-9f4345470831c08a7b38a9358b3e581c Not sure if this will make 15.1 though?

In the interim you might be able to change Vue's ContentType.TypeName to "htmlx" to work around this issue. Is that an option?

9swampy commented 7 years ago

I've built local and installed that, gets me working for now. I took a look but believe the TypeName change would break things, still haven't noticed anything missing using the original proposal. Fair enough it's only a temporary fix; I can live with that :) Thx.

madskristensen commented 7 years ago

I've mapped .vue files to the htmlx content type instead of creating a new one based on htmlx. That way it works around the issue described by @jramsay while keeping the much newer HTML editor mapping