Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
invalid @apply quick fix: check that base class name can be @applied
Brad Cornes <bradlc41@gmail.com>
4 years ago
1 changed files, 8 additions(+), 8 deletions(-)
M src/lsp/providers/codeActions/provideInvalidApplyCodeActions.ts -> src/lsp/providers/codeActions/provideInvalidApplyCodeActions.ts
diff --git a/src/lsp/providers/codeActions/provideInvalidApplyCodeActions.ts b/src/lsp/providers/codeActions/provideInvalidApplyCodeActions.ts
index 22c66036db3c9fbb8345ccd33311ca842cf92f77..346f2462f95b77ba7635ba884bb65bfaa087a8d3 100644
--- a/src/lsp/providers/codeActions/provideInvalidApplyCodeActions.ts
+++ b/src/lsp/providers/codeActions/provideInvalidApplyCodeActions.ts
@@ -22,6 +22,7 @@ import dset from 'dset'
 import selectorParser from 'postcss-selector-parser'
 import { flatten } from '../../../util/array'
 import { getClassNameMeta } from '../../util/getClassNameMeta'
+import { validateApply } from '../../util/validateApply'
 
 export async function provideInvalidApplyCodeActions(
   state: State,
@@ -173,11 +174,12 @@   classNameParts: string[],
   selector: string,
   important: boolean = false
 ) {
-  const baseClassName = dlv(
-    state.classNames.classNames,
-    classNameParts[classNameParts.length - 1]
-  )
-  if (!baseClassName) {
+  const baseClassName = classNameParts[classNameParts.length - 1]
+  const validatedBaseClassName = validateApply(state, [baseClassName])
+  if (
+    validatedBaseClassName === null ||
+    validatedBaseClassName.isApplyable === false
+  ) {
     return null
   }
   const meta = getClassNameMeta(state, classNameParts)
@@ -216,9 +218,7 @@   if (selector === null) return null
 
   let rule = {
     [selector]: {
-      [`@apply ${classNameParts[classNameParts.length - 1]}${
-        important ? ' !important' : ''
-      }`]: '',
+      [`@apply ${baseClassName}${important ? ' !important' : ''}`]: '',
     },
   }
   if (path.length) {