From 1e8d942290625236db95fadd28799a9addf83180 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Mon, 1 Sep 2025 12:01:44 -0400 Subject: [PATCH 1/2] Fix incorrect diagnostic for `--theme(--var inline)` --- .../src/util/find.test.ts | 34 +++++++++++++++++++ .../src/util/find.ts | 9 +++++ 2 files changed, 43 insertions(+) diff --git a/packages/tailwindcss-language-service/src/util/find.test.ts b/packages/tailwindcss-language-service/src/util/find.test.ts index da6ac60d..77414250 100644 --- a/packages/tailwindcss-language-service/src/util/find.test.ts +++ b/packages/tailwindcss-language-service/src/util/find.test.ts @@ -1156,3 +1156,37 @@ test('classFunctions are detected inside of arrays in javascript just after open }, ]) }) + +test("--theme's inline helper is not considered part of the path", async ({ expect }) => { + let file = createDocument({ + name: 'file.css', + lang: 'css', + settings: { + tailwindCSS: { + classFunctions: ['clsx'], + }, + }, + content: ` + .a { color: --theme(--my-color inline); } + .a { color: theme(--my-color inline); } + `, + }) + + let fns = findHelperFunctionsInDocument(file.state, file.doc) + + expect(fns).toEqual([ + { + helper: 'theme', + path: '--my-color', + ranges: { full: range(1, 26, 1, 43), path: range(1, 26, 1, 36) }, + }, + + // This is on purpose: + // The `theme()` function doesn't have an inline option only `--theme()`. + { + helper: 'theme', + path: '--my-color inline', + ranges: { full: range(2, 24, 2, 41), path: range(2, 24, 2, 41) }, + }, + ]) +}) diff --git a/packages/tailwindcss-language-service/src/util/find.ts b/packages/tailwindcss-language-service/src/util/find.ts index 1b39be69..1bd51cfa 100644 --- a/packages/tailwindcss-language-service/src/util/find.ts +++ b/packages/tailwindcss-language-service/src/util/find.ts @@ -557,6 +557,15 @@ export function findHelperFunctionsInRange( // Re-slice path = text.slice(pathStart, pathEnd) + // The `--theme(…)` function has an optional `inline` modifier that can appear at the end + // NOTE: The non-dashed `theme(…)` function does not have this + // + // TODO: We should validate that this modifier is `inline` and issue a diagnostic if its not + if (path.endsWith(' inline') && match.groups.helper === '--theme') { + path = path.slice(0, -7) + pathEnd -= 7 + } + fns.push({ helper, path, From 503e18dda77e5611276c0022ca5bf9e40b48ce15 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Mon, 1 Sep 2025 12:02:45 -0400 Subject: [PATCH 2/2] Update changelog --- packages/vscode-tailwindcss/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/vscode-tailwindcss/CHANGELOG.md b/packages/vscode-tailwindcss/CHANGELOG.md index f310e488..89112ab9 100644 --- a/packages/vscode-tailwindcss/CHANGELOG.md +++ b/packages/vscode-tailwindcss/CHANGELOG.md @@ -4,6 +4,7 @@ - Publish our fork of the CSS language server ([#1437](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1437)) - Suggest default variant values when they also support arbitrary values ([#1439](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1439)) +- Fix incorrect diagnostic for `--theme(--some-var inline)` ([#1443](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1443)) ## 0.14.26