@@ -79,7 +79,7 @@ module.exports = {
7979function parseTemplateLiteralStyles ( styles , input , range ) {
8080 const offset = input . quasis [ 0 ] . start ;
8181 const source = input . css ;
82- const parseStyle = docFixer ( source , input . parseOptions ) ;
82+ const parseStyle = docFixer ( offset , source , input . parseOptions ) ;
8383
8484 const nodes = [ ] ;
8585 let index = range [ 0 ] ;
@@ -106,14 +106,15 @@ function parseTemplateLiteralStyles(styles, input, range) {
106106}
107107
108108class LocalFixer {
109- constructor ( lines , style , templateParse ) {
109+ constructor ( offset , lines , style , templateParse ) {
110+ const startIndex = style . startIndex - offset
110111 let line = 0 ;
111- let column = style . startIndex ;
112+ let column = startIndex ;
112113 lines . some ( ( lineEndIndex , lineNumber ) => {
113- if ( lineEndIndex >= style . startIndex ) {
114+ if ( lineEndIndex >= startIndex ) {
114115 line = lineNumber -- ;
115116 if ( lineNumber in lines ) {
116- column = style . startIndex - lines [ lineNumber ] - 1 ;
117+ column = startIndex - lines [ lineNumber ] - 1 ;
117118 }
118119 return true ;
119120 }
@@ -177,7 +178,7 @@ class LocalFixer {
177178 }
178179}
179180
180- function docFixer ( source , opts ) {
181+ function docFixer ( offset , source , opts ) {
181182 let match ;
182183 const lines = [ ] ;
183184 reNewLine . lastIndex = 0 ;
@@ -187,7 +188,7 @@ function docFixer (source, opts) {
187188 lines . push ( source . length ) ;
188189 return function parseStyle ( style ) {
189190 const parse = style . syntax ? style . syntax . parse : postcssParse
190- return new LocalFixer ( lines , style , parse ) . parse ( opts ) ;
191+ return new LocalFixer ( offset , lines , style , parse ) . parse ( opts ) ;
191192 } ;
192193}
193194
0 commit comments