Skip to content

Commit 9bff008

Browse files
authored
Improve theme helper detection (#655)
1 parent 0625c6d commit 9bff008

File tree

1 file changed

+2
-9
lines changed
  • packages/tailwindcss-language-service/src/util

1 file changed

+2
-9
lines changed

packages/tailwindcss-language-service/src/util/find.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,7 @@ export function findHelperFunctionsInRange(
350350
range?: Range
351351
): DocumentHelperFunction[] {
352352
const text = getTextWithoutComments(doc, 'css', range)
353-
let matches = findAll(
354-
/(?<prefix>\s|^)(?<helper>config|theme)(?<innerPrefix>\(\s*)(?<path>[^)]*?)\s*\)/g,
355-
text
356-
)
353+
let matches = findAll(/\b(?<helper>config|theme)(?<innerPrefix>\(\s*)(?<path>[^)]*?)\s*\)/g, text)
357354

358355
return matches.map((match) => {
359356
let quotesBefore = ''
@@ -367,11 +364,7 @@ export function findHelperFunctionsInRange(
367364
}
368365
path = path.replace(/['"]*\s*$/, '')
369366

370-
let startIndex =
371-
match.index +
372-
match.groups.prefix.length +
373-
match.groups.helper.length +
374-
match.groups.innerPrefix.length
367+
let startIndex = match.index + match.groups.helper.length + match.groups.innerPrefix.length
375368

376369
return {
377370
helper: match.groups.helper === 'theme' ? 'theme' : 'config',

0 commit comments

Comments
 (0)