Skip to content

Commit

Permalink
Improve theme helper detection (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradlc committed Nov 7, 2022
1 parent 0625c6d commit 9bff008
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions packages/tailwindcss-language-service/src/util/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,7 @@ export function findHelperFunctionsInRange(
range?: Range
): DocumentHelperFunction[] {
const text = getTextWithoutComments(doc, 'css', range)
let matches = findAll(
/(?<prefix>\s|^)(?<helper>config|theme)(?<innerPrefix>\(\s*)(?<path>[^)]*?)\s*\)/g,
text
)
let matches = findAll(/\b(?<helper>config|theme)(?<innerPrefix>\(\s*)(?<path>[^)]*?)\s*\)/g, text)

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

let startIndex =
match.index +
match.groups.prefix.length +
match.groups.helper.length +
match.groups.innerPrefix.length
let startIndex = match.index + match.groups.helper.length + match.groups.innerPrefix.length

return {
helper: match.groups.helper === 'theme' ? 'theme' : 'config',
Expand Down

0 comments on commit 9bff008

Please sign in to comment.