@@ -81,6 +81,17 @@ let vueStates = {
81
81
} ,
82
82
html : {
83
83
htmlBlockEnd : { match : '</template>' , pop : 1 } ,
84
+ nestedBlockStart : { match : '<template' , push : 'nestedBlock' } ,
85
+ ...text ,
86
+ } ,
87
+ nestedBlock : {
88
+ nestedStart : { match : '>' , next : 'nested' } ,
89
+ nestedBlockEnd : { match : '/>' , pop : 1 } ,
90
+ ...text ,
91
+ } ,
92
+ nested : {
93
+ nestedBlockEnd : { match : '</template>' , pop : 1 } ,
94
+ nestedBlockStart : { match : '<template' , push : 'nestedBlock' } ,
84
95
...text ,
85
96
} ,
86
97
}
@@ -124,19 +135,21 @@ export function getLanguageBoundaries(
124
135
125
136
try {
126
137
for ( let token of lexer ) {
127
- if ( token . type . endsWith ( 'BlockStart' ) ) {
128
- let position = indexToPosition ( text , offset )
129
- if ( ! boundaries [ boundaries . length - 1 ] . range . end ) {
138
+ if ( ! token . type . startsWith ( 'nested' ) ) {
139
+ if ( token . type . endsWith ( 'BlockStart' ) ) {
140
+ let position = indexToPosition ( text , offset )
141
+ if ( ! boundaries [ boundaries . length - 1 ] . range . end ) {
142
+ boundaries [ boundaries . length - 1 ] . range . end = position
143
+ }
144
+ type = token . type . replace ( / B l o c k S t a r t $ / , '' )
145
+ boundaries . push ( { type, range : { start : position , end : undefined } } )
146
+ } else if ( token . type . endsWith ( 'BlockEnd' ) ) {
147
+ let position = indexToPosition ( text , offset )
130
148
boundaries [ boundaries . length - 1 ] . range . end = position
149
+ boundaries . push ( { type : defaultType , range : { start : position , end : undefined } } )
150
+ } else if ( token . type === 'lang' ) {
151
+ boundaries [ boundaries . length - 1 ] . type = token . text
131
152
}
132
- type = token . type . replace ( / B l o c k S t a r t $ / , '' )
133
- boundaries . push ( { type, range : { start : position , end : undefined } } )
134
- } else if ( token . type . endsWith ( 'BlockEnd' ) ) {
135
- let position = indexToPosition ( text , offset )
136
- boundaries [ boundaries . length - 1 ] . range . end = position
137
- boundaries . push ( { type : defaultType , range : { start : position , end : undefined } } )
138
- } else if ( token . type === 'lang' ) {
139
- boundaries [ boundaries . length - 1 ] . type = token . text
140
153
}
141
154
offset += token . text . length
142
155
}
0 commit comments