-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
Syntax highlighting break for </template and > not in same line in template #1211
Comments
Ok something in template broken highlighting
If reformat template all work fine, but this format I get from lint --fix |
I'm experiencing the same issue, script and style sections for one file no longer have syntax highlighting. |
I have created a reproducible repo for this case, which can be pulled down and ran from here /~https://github.com/dombavetta/vetur-template-interpolation-issues. The problematic file -> /~https://github.com/dombavetta/vetur-template-interpolation-issues/blob/master/pages/test.vue The issue appears to be caused by this line and the way it is formatted (24) Removing that span resolves the highlighting issues. |
Man, why would you write your code like this... |
@octref I doubt he purposely wrote it like that. eslint/prettier will format it like that to prevent unnecessary whitespace from making it into the markup. Thats what it does for me at least.. I know its ugly but I guess theres some good reasoning behind it. For me its easier to just submit to the formatters that fight them or clutter my code with disable and ignore comments. |
This doesn't seem to be possible with TextMate:
|
this formatting is a result of whitespace-sensitive-formatting in prettier 1.15 and later also, it only breaks the syntax highlighting if it is a breaks highlighting: <template v-else
>abc</template
> works fine (replaced template with div tag only): <div v-else
>abc</div
> |
I just faced the same problem. The following code breaks highlightings of VS Code. <template v-if="value"
>Some message</template
>
<template v-else
>Another message</template
> But thanks to @fabsenet, I figured out some workarounds of this problem. 1. Use
|
Since Prettier enabled whitespace-sensitive-formatting by default, more and more of my Vue SFCs have become blobs of all-white JavaScript because of this bug. I don't yet have a solution, but here are my notes:
This would introduce a new restriction on how SFCs must be formatted, but it would enable differentiating the two types of closing |
End the vue-html only with a `</template>` at the beginning of a line. Because the `<template>` tag starts a grammar in source.vue files and can also be used a a tag *within* that grammar, the closing `</template>` of the grammar must be distinguishable from the same closing tag within the vue-html grammar. This enables removing the recursive application of the vue-html grammar within the vue-html grammar because source.vue can reliably know when a `</template>` should end the grammar. * New restriction: there can be only 1 closing `</template>` within a Vue single-file component (SFC) otherwise the vue-html grammar will be closed early. That closing `</template>` must also appear at the beginning of a line. Because this follows Vue formatting guidelines, this should have zero impact on users who following those guidelines. Fixes vuejs#1211
As I've just bumped into this: syntax highlighting for |
Info
Problem
Reproducible Case
I don't know, this behavior in one file.
I restarted VS, rename file, and reinstalled vetur. But highlighting not work in this file,
The text was updated successfully, but these errors were encountered: