Skip to content

Commit 15bc6db

Browse files
committed
Improve theme helper detection
1 parent 64aa320 commit 15bc6db

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

packages/tailwindcss-language-service/src/diagnostics/getInvalidConfigPathDiagnostics.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export function getInvalidConfigPathDiagnostics(
179179
ranges.forEach((range) => {
180180
let text = document.getText(range)
181181
let matches = findAll(
182-
/(?<prefix>\s|^)(?<helper>config|theme)\((?<quote>['"])(?<key>[^)]+)\k<quote>\)/g,
182+
/(?<prefix>\s|^)(?<helper>config|theme)\((?<quote>['"])(?<key>[^)]+)\k<quote>[^)]*\)/g,
183183
text
184184
)
185185

packages/tailwindcss-language-service/src/hoverProvider.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function provideCssHelperHover(state: State, document: TextDocument, position: P
2828
end: { line: position.line + 1, character: 0 },
2929
})
3030

31-
const match = line.match(/(?<helper>theme|config)\((?<quote>['"])(?<key>[^)]+)\k<quote>\)/)
31+
const match = line.match(/(?<helper>theme|config)\((?<quote>['"])(?<key>[^)]+)\k<quote>[^)]*\)/)
3232

3333
if (match === null) return null
3434

packages/tailwindcss-language-service/src/util/find.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ export function findHelperFunctionsInRange(
341341
): DocumentHelperFunction[] {
342342
const text = doc.getText(range)
343343
const matches = findAll(
344-
/(?<before>^|\s)(?<helper>theme|config)\((?:(?<single>')([^']+)'|(?<double>")([^"]+)")\)/gm,
344+
/(?<before>^|\s)(?<helper>theme|config)\((?:(?<single>')([^']+)'|(?<double>")([^"]+)")[^)]*\)/gm,
345345
text
346346
)
347347

0 commit comments

Comments
 (0)