diff --git a/packages/tailwindcss-language-service/src/completionProvider.ts b/packages/tailwindcss-language-service/src/completionProvider.ts index d8bee18..63a5edf 100644 --- a/packages/tailwindcss-language-service/src/completionProvider.ts +++ b/packages/tailwindcss-language-service/src/completionProvider.ts @@ -614,7 +614,7 @@ function provideCssHelperCompletions( const match = text .substr(0, text.length - 1) // don't include that extra character from earlier - .match(/\b(?config|theme)\(\s*['"]?(?[^)'"]*)$/) + .match(/[\s:;/*(){}](?config|theme)\(\s*['"]?(?[^)'"]*)$/) if (match === null) { return null diff --git a/packages/tailwindcss-language-service/src/util/find.ts b/packages/tailwindcss-language-service/src/util/find.ts index 0283865..1977ef8 100644 --- a/packages/tailwindcss-language-service/src/util/find.ts +++ b/packages/tailwindcss-language-service/src/util/find.ts @@ -350,7 +350,10 @@ export function findHelperFunctionsInRange( range?: Range ): DocumentHelperFunction[] { const text = getTextWithoutComments(doc, 'css', range) - let matches = findAll(/\b(?config|theme)(?\(\s*)(?[^)]*?)\s*\)/g, text) + let matches = findAll( + /(?[\s:;/*(){}])(?config|theme)(?\(\s*)(?[^)]*?)\s*\)/g, + text + ) return matches.map((match) => { let quotesBefore = '' @@ -364,7 +367,11 @@ export function findHelperFunctionsInRange( } path = path.replace(/['"]*\s*$/, '') - let startIndex = match.index + match.groups.helper.length + match.groups.innerPrefix.length + let startIndex = + match.index + + match.groups.prefix.length + + match.groups.helper.length + + match.groups.innerPrefix.length return { helper: match.groups.helper === 'theme' ? 'theme' : 'config',