@@ -123,8 +123,8 @@ export function register({ sourceFiles, getTsLs, htmlLs, pugLs, scriptTsLs, modu
123123 return result ;
124124 }
125125 function getHtmlResult ( sourceFile : SourceFile ) {
126- const result : TokenData [ ] = [ ] ;
127126
127+ const result : TokenData [ ] = [ ] ;
128128 const templateScriptData = sourceFile . getTemplateScriptData ( ) ;
129129 const components = new Set ( [
130130 ...templateScriptData . components ,
@@ -133,14 +133,19 @@ export function register({ sourceFiles, getTsLs, htmlLs, pugLs, scriptTsLs, modu
133133
134134 for ( const sourceMap of [ ...sourceFile . getHtmlSourceMaps ( ) , ...sourceFile . getPugSourceMaps ( ) ] ) {
135135
136- const inSourceMap = [ ...sourceMap . mappings ] . some ( mapping =>
137- ( mapping . sourceRange . start >= offsetRange . start && mapping . sourceRange . start <= offsetRange . end )
138- || ( mapping . sourceRange . end >= offsetRange . start && mapping . sourceRange . end <= offsetRange . end )
139- ) ;
140- if ( ! inSourceMap )
136+ let htmlStart = sourceMap . getMappedRange ( offsetRange . start ) ?. [ 0 ] . start ;
137+ if ( htmlStart === undefined ) {
138+ for ( const mapping of sourceMap . mappings ) {
139+ if ( mapping . sourceRange . end >= offsetRange . start ) {
140+ if ( htmlStart === undefined || mapping . mappedRange . start < htmlStart ) {
141+ htmlStart = mapping . mappedRange . start ;
142+ }
143+ }
144+ }
145+ }
146+ if ( htmlStart === undefined )
141147 continue ;
142148
143- const htmlStart = sourceMap . getMappedRange ( offsetRange . start ) ?. [ 0 ] . start ?? 0 ;
144149 const docText = sourceMap . mappedDocument . getText ( ) ;
145150 const scanner = sourceMap . language === 'html'
146151 ? htmlLs . createScanner ( docText , htmlStart )
0 commit comments