Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
don't provide quick fix for @apply class name which has multiple rules
Brad Cornes <bradlc41@gmail.com>
4 years ago
1 changed files, 16 additions(+), 13 deletions(-)
M src/lsp/providers/codeActionProvider/index.ts -> src/lsp/providers/codeActionProvider/index.ts
diff --git a/src/lsp/providers/codeActionProvider/index.ts b/src/lsp/providers/codeActionProvider/index.ts
index 62bdb128c3e49cf2cd5895a14dff8cfa7064aef1..22298dad00a8abe4bea08c7a41651849e6c5e6dd 100644
--- a/src/lsp/providers/codeActionProvider/index.ts
+++ b/src/lsp/providers/codeActionProvider/index.ts
@@ -111,22 +111,18 @@ }
 
 function classNameToAst(
   state: State,
-  className: string,
-  selector: string = `.${className}`,
+  classNameParts: string[],
+  selector: string,
   important: boolean = false
 ) {
-  const parts = getClassNameParts(state, className)
-  if (!parts) {
-    return null
-  }
   const baseClassName = dlv(
     state.classNames.classNames,
-    parts[parts.length - 1]
+    classNameParts[classNameParts.length - 1]
   )
   if (!baseClassName) {
     return null
   }
-  const info = dlv(state.classNames.classNames, parts)
+  const info = dlv(state.classNames.classNames, classNameParts)
   let context = info.__context || []
   let pseudo = info.__pseudo || []
   const globalContexts = state.classNames.context
@@ -139,8 +135,8 @@   if (!isObject(screens)) screens = {}
   screens = Object.keys(screens)
   const path = []
 
-  for (let i = 0; i < parts.length - 1; i++) {
-    let part = parts[i]
+  for (let i = 0; i < classNameParts.length - 1; i++) {
+    let part = classNameParts[i]
     let common = globalContexts[part]
     if (!common) return null
     if (screens.includes(part)) {
@@ -158,7 +154,7 @@   }
   let rule = {
     // TODO: use proper selector parser
     [selector + pseudo.join('')]: {
-      [`@apply ${parts[parts.length - 1]}${
+      [`@apply ${classNameParts[classNameParts.length - 1]}${
         important ? ' !important' : ''
       }`]: '',
     },
@@ -221,6 +217,14 @@   let totalClassNamesInClassList = diagnostic.className.classList.classList.split(
     /\s+/
   ).length
 
+  let className = diagnostic.className.className
+  let classNameParts = getClassNameParts(state, className)
+  let classNameInfo = dlv(state.classNames.classNames, classNameParts)
+
+  if (Array.isArray(classNameInfo)) {
+    return []
+  }
+
   if (!isCssDoc(state, document)) {
     let languageBoundaries = getLanguageBoundaries(state, document)
     if (!languageBoundaries) return []
@@ -259,10 +263,9 @@                 // keep looking
                 return true
               }
 
-              let className = diagnostic.className.className
               let ast = classNameToAst(
                 state,
-                className,
+                classNameParts,
                 rule.selector,
                 diagnostic.className.classList.important
               )