File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -38,10 +38,11 @@ const plugin: VueLanguagePlugin = ({ modules }) => {
3838 get ( target , prop ) {
3939 if ( prop === 'offset' ) {
4040 const htmlOffset = target . offset ;
41+ const nums : number [ ] = [ ] ;
4142 for ( const mapped of map . getSourceOffsets ( htmlOffset ) ) {
42- return mapped [ 0 ] ;
43+ nums . push ( mapped [ 0 ] ) ;
4344 }
44- return - 1 ;
45+ return Math . max ( - 1 , ... nums ) ;
4546 }
4647 const value = target [ prop ] ;
4748 if ( typeof value === 'object' ) {
Original file line number Diff line number Diff line change @@ -129,13 +129,17 @@ export function getComponentSpans(
129129 }
130130 if ( node . type === 1 satisfies vue . CompilerDOM . NodeTypes . ELEMENT ) {
131131 if ( components . has ( node . tag ) ) {
132+ let start = node . loc . start . offset ;
133+ if ( template . lang === 'html' ) {
134+ start += '<' . length ;
135+ }
132136 result . push ( {
133- start : node . loc . start . offset + node . loc . source . indexOf ( node . tag ) ,
137+ start,
134138 length : node . tag . length ,
135139 } ) ;
136140 if ( template . lang === 'html' && ! node . isSelfClosing ) {
137141 result . push ( {
138- start : node . loc . start . offset + node . loc . source . lastIndexOf ( node . tag ) ,
142+ start : start + node . loc . source . lastIndexOf ( node . tag ) ,
139143 length : node . tag . length ,
140144 } ) ;
141145 }
You can’t perform that action at this time.
0 commit comments