From dd8774ebd7be27dd2c25ed2daabb0a86155ecba5 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 5 Feb 2025 18:10:57 +0100 Subject: [PATCH 1/3] =?UTF-8?q?Allow=20hover=20over=20`--theme(=E2=80=A6)`?= =?UTF-8?q?=20function=20in=20`@media`=20rule=20without=20spaces?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/hover/hover.test.js | 18 ++++++++++++++++++ .../src/util/find.ts | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/tailwindcss-language-server/tests/hover/hover.test.js b/packages/tailwindcss-language-server/tests/hover/hover.test.js index 8867a804..741a4630 100644 --- a/packages/tailwindcss-language-server/tests/hover/hover.test.js +++ b/packages/tailwindcss-language-server/tests/hover/hover.test.js @@ -272,6 +272,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) => { diff --git a/packages/tailwindcss-language-service/src/util/find.ts b/packages/tailwindcss-language-service/src/util/find.ts index 31572cfa..df0b5e37 100644 --- a/packages/tailwindcss-language-service/src/util/find.ts +++ b/packages/tailwindcss-language-service/src/util/find.ts @@ -350,7 +350,7 @@ export function findHelperFunctionsInRange( ): DocumentHelperFunction[] { const text = getTextWithoutComments(doc, 'css', range) let matches = findAll( - /(?[\s:;/*(){}])(?config|theme|--theme)(?\(\s*)(?[^)]*?)\s*\)/g, + /(?[\W])(?config|theme|--theme)(?\(\s*)(?[^)]*?)\s*\)/g, text, ) From d02b5f26224dc6e7b607e45fe0fb6ae343c023af Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 5 Feb 2025 18:20:56 +0100 Subject: [PATCH 2/3] =?UTF-8?q?Add=20test=20for=20`theme(=E2=80=A6)`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/hover/hover.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/tailwindcss-language-server/tests/hover/hover.test.js b/packages/tailwindcss-language-server/tests/hover/hover.test.js index 741a4630..84841680 100644 --- a/packages/tailwindcss-language-server/tests/hover/hover.test.js +++ b/packages/tailwindcss-language-server/tests/hover/hover.test.js @@ -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) => { From c0d801f0112a026dafee29cde51f5574ade0c8fc Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 5 Feb 2025 18:23:10 +0100 Subject: [PATCH 3/3] Add change log --- packages/vscode-tailwindcss/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vscode-tailwindcss/CHANGELOG.md b/packages/vscode-tailwindcss/CHANGELOG.md index 2df89979..090cb831 100644 --- a/packages/vscode-tailwindcss/CHANGELOG.md +++ b/packages/vscode-tailwindcss/CHANGELOG.md @@ -2,7 +2,7 @@ ## Prerelease -- Nothing yet! +- Ensure hover information for `theme(…)` and other functions are shown when used in `@media` queries ([#1172](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1172)) ## 0.14.3