File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
packages/tailwindcss-language-service/src/util Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -348,6 +348,22 @@ export function findHelperFunctionsInDocument(
348348 )
349349}
350350
351+ function getFirstCommaIndex ( str : string ) : number | null {
352+ let quoteChar : string | undefined
353+ for ( let i = 0 ; i < str . length ; i ++ ) {
354+ let char = str [ i ]
355+ if ( char === ',' && ! quoteChar ) {
356+ return i
357+ }
358+ if ( ! quoteChar && ( char === '"' || char === "'" ) ) {
359+ quoteChar = char
360+ } else if ( char === quoteChar ) {
361+ quoteChar = undefined
362+ }
363+ }
364+ return null
365+ }
366+
351367export function findHelperFunctionsInRange (
352368 doc : TextDocument ,
353369 range ?: Range
@@ -360,7 +376,12 @@ export function findHelperFunctionsInRange(
360376
361377 return matches . map ( ( match ) => {
362378 let quotesBefore = ''
363- let path = match . groups . path . replace ( / [ ' " ] + $ / , '' ) . replace ( / ^ [ ' " ] + / , ( m ) => {
379+ let path = match . groups . path
380+ let commaIndex = getFirstCommaIndex ( path )
381+ if ( commaIndex !== null ) {
382+ path = path . slice ( 0 , commaIndex ) . trimEnd ( )
383+ }
384+ path = path . replace ( / [ ' " ] + $ / , '' ) . replace ( / ^ [ ' " ] + / , ( m ) => {
364385 quotesBefore = m
365386 return ''
366387 } )
You can’t perform that action at this time.
0 commit comments