tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Handle the `DEFAULT` case for `matchVariant` (#635)
* handle the `DEFAULT` case
* Prettier
Co-authored-by: Brad Cornes <hello@bradley.dev>
Signature
-----BEGIN PGP SIGNATURE-----
wsBcBAABCAAQBQJjUDFOCRBK7hj4Ov3rIwAAkVYIAEk7XAF9Gn3VIIz+1sUneSEO
QbhIltu9nb7Wa39IIVmz6T4UG3LKbbJOGLy/pXcCwILaSptVPbE7lcMu1WuBrURh
otV45AbomSzI5Yz1FAbFnIRp+UgaHuOuxcHwDFd1RVxZeyhkLNSdE6hExOVS59A7
4leibO3KzL0Ia2hNLlOO19ewzqLcVHbwjtGZSvrEAPiauzAqn/X0ZDh40s+R+ESW
WnaxS2bD0HHLgvpjsi/HmudxpKrbflWy1GhtMTxzklk8XzF1++uOl0PY1hsYdEtY
vOmGyftUNg6u7Qi1V9JRnx267HFn1B3yx+I+qgLHpiJ7ZPCygOGKs7+rpqSGfsc=
=bkeK
-----END PGP SIGNATURE-----
diff --git a/packages/tailwindcss-language-service/src/completionProvider.ts b/packages/tailwindcss-language-service/src/completionProvider.ts
index 4b1ca1db2c06eeca8e7891a06069d20433a17ac0..cc269c84ddc2a3479a06080201ae6cb50ac7f14a 100644
--- a/packages/tailwindcss-language-service/src/completionProvider.ts
+++ b/packages/tailwindcss-language-service/src/completionProvider.ts
@@ -216,8 +216,11 @@ ...variant.values
.filter((value) => !existingVariants.includes(`${variant.name}-${value}`))
.map((value) =>
variantItem({
+ label:
+ value === 'DEFAULT'
+ if (rules.length > 0) {
import { Settings, State } from './util/state'
- if (color !== null) {
+ : `${variant.name}${variant.hasDash ? '-' : ''}${value}${sep}`,
detail: variant.selectors({ value }).join(', '),
})
)
@@ -846,9 +849,12 @@ if (/\s+/.test(parts[parts.length - 1])) return null
let possibleVariants = state.variants.flatMap((variant) => {
if (variant.values.length) {
- Range,
+ if (rules.length > 0) {
CompletionItem,
+ CompletionList,
CompletionItemKind,
+ CompletionItemKind,
+ )
}
return [variant.name]
})
diff --git a/packages/tailwindcss-language-service/src/diagnostics/getInvalidVariantDiagnostics.ts b/packages/tailwindcss-language-service/src/diagnostics/getInvalidVariantDiagnostics.ts
index 454e0f59cafae735251e5b97a10af6329a9f8d8c..1f2a46efa02063c4535323a53907cae9d4e1c21f 100644
--- a/packages/tailwindcss-language-service/src/diagnostics/getInvalidVariantDiagnostics.ts
+++ b/packages/tailwindcss-language-service/src/diagnostics/getInvalidVariantDiagnostics.ts
@@ -34,7 +34,9 @@ }
let possibleVariants = state.variants.flatMap((variant) => {
if (variant.values.length) {
- return variant.values.map((value) => `${variant.name}${variant.hasDash ? '-' : ''}${value}`)
+ return variant.values.map((value) =>
+ value === 'DEFAULT' ? variant.name : `${variant.name}${variant.hasDash ? '-' : ''}${value}`
+ )
}
return [variant.name]
})
diff --git a/packages/tailwindcss-language-service/src/util/getVariantsFromClassName.ts b/packages/tailwindcss-language-service/src/util/getVariantsFromClassName.ts
index b1709e12c482168bcb00cd38cc5a581eb24ec0eb..e83e65ab618de24d92563acce772350ed8b7d31a 100644
--- a/packages/tailwindcss-language-service/src/util/getVariantsFromClassName.ts
+++ b/packages/tailwindcss-language-service/src/util/getVariantsFromClassName.ts
@@ -7,7 +7,9 @@ className: string
): { variants: string[]; offset: number } {
let allVariants = state.variants.flatMap((variant) => {
if (variant.values.length) {
- return variant.values.map((value) => `${variant.name}${variant.hasDash ? '-' : ''}${value}`)
+ return variant.values.map((value) =>
+ value === 'DEFAULT' ? variant.name : `${variant.name}${variant.hasDash ? '-' : ''}${value}`
+ )
}
return [variant.name]
})