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
34 changes: 34 additions & 0 deletions packages/tailwindcss-language-service/src/util/find.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
},
])
})
9 changes: 9 additions & 0 deletions packages/tailwindcss-language-service/src/util/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/vscode-tailwindcss/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down