From 9bff008eaedf56f7f34d46a656e672d99b4fe933 Mon Sep 17 00:00:00 2001 From: Brad Cornes Date: Mon, 7 Nov 2022 12:10:16 +0000 Subject: [PATCH] Improve `theme` helper detection (#655) --- .../tailwindcss-language-service/src/util/find.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/tailwindcss-language-service/src/util/find.ts b/packages/tailwindcss-language-service/src/util/find.ts index 8dd6ad9..0283865 100644 --- a/packages/tailwindcss-language-service/src/util/find.ts +++ b/packages/tailwindcss-language-service/src/util/find.ts @@ -350,10 +350,7 @@ export function findHelperFunctionsInRange( range?: Range ): DocumentHelperFunction[] { const text = getTextWithoutComments(doc, 'css', range) - let matches = findAll( - /(?\s|^)(?config|theme)(?\(\s*)(?[^)]*?)\s*\)/g, - text - ) + let matches = findAll(/\b(?config|theme)(?\(\s*)(?[^)]*?)\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',