Improve `theme` helper detection (#655)

master
Brad Cornes 2022-11-07 12:10:16 +00:00 committed by GitHub
parent 0625c6de35
commit 9bff008eae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 9 deletions

View File

@ -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 = ''
@ -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',