File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
packages/language-core/lib/plugins Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,24 @@ const plugin: VueLanguagePlugin = ({ vueCompilerOptions }) => {
19
19
if ( languageId !== 'vue' ) {
20
20
return ;
21
21
}
22
- return parse ( content ) ;
22
+ const sfc = parse ( content ) ;
23
+ for ( const error of sfc . errors ) {
24
+ // Handle 'Element is missing end tag.' error, see #4893
25
+ if (
26
+ 'code' in error && error . code === 24 && sfc . descriptor . template
27
+ && error . loc ?. start . line === sfc . descriptor . template . loc . start . line
28
+ ) {
29
+ const template = sfc . descriptor . template ;
30
+ const templateText = template . content ;
31
+ const endTagOffset = templateText . lastIndexOf ( '<' ) ;
32
+ const endTagText = templateText . slice ( endTagOffset ) . trimEnd ( ) ;
33
+ if ( '</template>' . startsWith ( endTagText ) ) {
34
+ sfc . descriptor . template . loc . end . offset = template . loc . start . offset + endTagOffset ;
35
+ template . content = templateText . slice ( 0 , endTagOffset ) ;
36
+ }
37
+ }
38
+ }
39
+ return sfc ;
23
40
} ,
24
41
25
42
updateSFC ( sfc , change ) {
You can’t perform that action at this time.
0 commit comments