Skip to content

Simplify details for utility completions #1356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 20 additions & 7 deletions packages/tailwindcss-language-service/src/completionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2280,24 +2280,37 @@ export async function resolveCompletionItem(
if (state.v4) {
if (item.kind === 9) return item
if (item.detail && item.documentation) return item

let base = state.designSystem.compile([className])[0]
let root = state.designSystem.compile([[...variants, className].join(state.separator)])[0]

let rules = root.nodes.filter((node) => node.type === 'rule')
if (rules.length === 0) return item

if (!item.detail) {
if (rules.length === 1) {
let decls: postcss.Declaration[] = []

root.walkDecls((node) => {
// Remove any `@property` rules
base = base.clone()
base.walkAtRules((rule) => {
// Ignore declarations inside `@property` rules
if (rule.name === 'property') {
rule.remove()
}

// Ignore declarations @supports (-moz-orient: inline)
// this is a hack used for `@property` fallbacks in Firefox
if (rule.name === 'supports' && rule.params === '(-moz-orient: inline)') {
rule.remove()
}
})

base.walkDecls((node) => {
decls.push(node)
})

item.detail = await jit.stringifyDecls(
state,
postcss.rule({
nodes: decls,
}),
)
item.detail = await jit.stringifyDecls(state, postcss.rule({ nodes: decls }))
} else {
item.detail = `${rules.length} rules`
}
Expand Down
2 changes: 2 additions & 0 deletions packages/vscode-tailwindcss/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
- Fix error when using VSCode < 1.78 ([#1353](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1353))
- Don’t skip suggesting empty variant implementations ([#1352](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1352))
- Handle helper function lookups in nested parens ([#1354](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1354))
- Hide `@property` declarations from completion details ([#1356](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1356))
- Hide variant-provided declarations from completion details for a utility ([#1356](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1356))

# 0.14.16

Expand Down