Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
36 changes: 36 additions & 0 deletions packages/tailwindcss-language-server/tests/hover/hover.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,24 @@ withFixture('basic', (c) => {
},
},
})

testHover('theme() works inside @media queries', {
lang: 'tailwindcss',
text: `@media (width>=theme(screens.xl)) { .foo { color: red; } }`,
position: { line: 0, character: 21 },

exact: true,
expected: {
contents: {
kind: 'markdown',
value: ['```plaintext', '1280px', '```'].join('\n'),
},
range: {
start: { line: 0, character: 21 },
end: { line: 0, character: 31 },
},
},
})
})

withFixture('v4/basic', (c) => {
Expand Down Expand Up @@ -272,6 +290,24 @@ withFixture('v4/basic', (c) => {
end: { line: 2, character: 18 },
},
})

testHover('--theme() works inside @media queries', {
lang: 'tailwindcss',
text: `@media (width>=--theme(--breakpoint-xl)) { .foo { color: red; } }`,
position: { line: 0, character: 23 },

exact: true,
expected: {
contents: {
kind: 'markdown',
value: ['```plaintext', '80rem /* 1280px */', '```'].join('\n'),
},
range: {
start: { line: 0, character: 23 },
end: { line: 0, character: 38 },
},
},
})
})

withFixture('v4/css-loading-js', (c) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/tailwindcss-language-service/src/util/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ export function findHelperFunctionsInRange(
): DocumentHelperFunction[] {
const text = getTextWithoutComments(doc, 'css', range)
let matches = findAll(
/(?<prefix>[\s:;/*(){}])(?<helper>config|theme|--theme)(?<innerPrefix>\(\s*)(?<path>[^)]*?)\s*\)/g,
/(?<prefix>[\W])(?<helper>config|theme|--theme)(?<innerPrefix>\(\s*)(?<path>[^)]*?)\s*\)/g,
text,
)

Expand Down