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(
348
348
)
349
349
}
350
350
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
+
351
367
export function findHelperFunctionsInRange (
352
368
doc : TextDocument ,
353
369
range ?: Range
@@ -360,7 +376,12 @@ export function findHelperFunctionsInRange(
360
376
361
377
return matches . map ( ( match ) => {
362
378
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 ) => {
364
385
quotesBefore = m
365
386
return ''
366
387
} )
You can’t perform that action at this time.
0 commit comments