Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ function provideCssHelperCompletions(

const match = text
.substr(0, text.length - 1) // don't include that extra character from earlier
.match(/\b(?<helper>config|theme)\(\s*['"]?(?<path>[^)'"]*)$/)
.match(/[\s:;/*(){}](?<helper>config|theme)\(\s*['"]?(?<path>[^)'"]*)$/)

if (match === null) {
return null
Expand Down
11 changes: 9 additions & 2 deletions packages/tailwindcss-language-service/src/util/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,10 @@ export function findHelperFunctionsInRange(
range?: Range
): DocumentHelperFunction[] {
const text = getTextWithoutComments(doc, 'css', range)
let matches = findAll(/\b(?<helper>config|theme)(?<innerPrefix>\(\s*)(?<path>[^)]*?)\s*\)/g, text)
let matches = findAll(
/(?<prefix>[\s:;/*(){}])(?<helper>config|theme)(?<innerPrefix>\(\s*)(?<path>[^)]*?)\s*\)/g,
text
)

return matches.map((match) => {
let quotesBefore = ''
Expand All @@ -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',
Expand Down