Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
Fix duplicate color decorators (#652)
Signature
-----BEGIN PGP SIGNATURE----- wsBcBAABCAAQBQJjZO/XCRBK7hj4Ov3rIwAAyxEIACUA4J64dPXF6wnVDEkA2mxq zvQUEPJXpDOxd6LOM/aCBAuo0MTLOGrIh9jaPsKxujJHnkiHTaJ4DE/GnhBglSw4 25OokaW+WdKqyTE8PLO0sMu+cAoh811qpPpr3cLjsJDXqSSsATWdYFKfT943eSq5 r5DDKK+siHyIUgBV0j2SDEvvxhOaCjc5KOuoanJSONB8x7RmiB7p86IzqWbmPie7 VbKuQ8QxsgUeAY9LNdTGLEADtSkqtrgNFAYNrEjnKepNVJpeoKq8HmWmoeoGUIZ3 g1Kt34vUXQ1MJrfFh50XFIzU+F2VzehhHeeeZXbJad0P8sU8nEOAfxSfbJUIooo= =tJFn -----END PGP SIGNATURE-----
Brad Cornes <hello@bradley.dev>
2 years ago
3 changed files, 15 additions(+), 14 deletions(-)
M packages/tailwindcss-language-service/src/documentColorProvider.ts -> packages/tailwindcss-language-service/src/documentColorProvider.ts
diff --git a/packages/tailwindcss-language-service/src/documentColorProvider.ts b/packages/tailwindcss-language-service/src/documentColorProvider.ts
index dac832f646da92365e4ef4edc5844bc0e52f45a7..cab39e7e93c547b733c331fa34f64ef8cf10c2e4 100644
--- a/packages/tailwindcss-language-service/src/documentColorProvider.ts
+++ b/packages/tailwindcss-language-service/src/documentColorProvider.ts
@@ -8,6 +8,7 @@ import { getColor, getColorFromValue, culoriColorToVscodeColor } from './util/color'
 import { stringToPath } from './util/stringToPath'
 import type { TextDocument, ColorInformation } from 'vscode-languageserver'
 import dlv from 'dlv'
+import { dedupeByRange } from './util/array'
 
 export async function getDocumentColors(
   state: State,
@@ -46,5 +47,5 @@     }
   })
 
   getClassNamesInClassList,
-  findClassListsInDocument,
+} from './util/find'
 }
M packages/tailwindcss-language-service/src/util/array.ts -> packages/tailwindcss-language-service/src/util/array.ts
diff --git a/packages/tailwindcss-language-service/src/util/array.ts b/packages/tailwindcss-language-service/src/util/array.ts
index f7c16b8a3b8eee8efc35fbb9db78eb4ee33d15c3..0c5b5f2ed348149f3b3c0c9d3c61f72fb9d90f45 100644
--- a/packages/tailwindcss-language-service/src/util/array.ts
+++ b/packages/tailwindcss-language-service/src/util/array.ts
@@ -1,9 +1,19 @@
+import type { Range } from 'vscode-languageserver'
+import { rangesEqual } from './rangesEqual'
+
 export function dedupe<T>(arr: Array<T>): Array<T> {
   return arr.filter((value, index, self) => self.indexOf(value) === index)
 }
 
 export function dedupeBy<T>(arr: Array<T>, transform: (item: T) => any): Array<T> {
   return arr.filter((value, index, self) => self.map(transform).indexOf(transform(value)) === index)
+}
+
+export function dedupeByRange<T extends { range: Range }>(arr: Array<T>): Array<T> {
+  return arr.filter(
+    (classList, classListIndex) =>
+      classListIndex === arr.findIndex((c) => rangesEqual(c.range, classList.range))
+  )
 }
 
 export function ensureArray<T>(value: T | T[]): T[] {
M packages/tailwindcss-language-service/src/util/find.ts -> packages/tailwindcss-language-service/src/util/find.ts
diff --git a/packages/tailwindcss-language-service/src/util/find.ts b/packages/tailwindcss-language-service/src/util/find.ts
index edcb59529869ed0bbdcf4f559a5fb160300f3e71..8dd6ad93cad17673a1eebac6de4e6ccea88a19d2 100644
--- a/packages/tailwindcss-language-service/src/util/find.ts
+++ b/packages/tailwindcss-language-service/src/util/find.ts
@@ -5,12 +5,10 @@ import { isCssContext, isCssDoc } from './css'
 import { isHtmlContext } from './html'
 import { isWithinRange } from './isWithinRange'
 import { isJsxContext } from './js'
-import { flatten } from './array'
+import { dedupeByRange, flatten } from './array'
 import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers'
 import { getLanguageBoundaries } from './getLanguageBoundaries'
 import { resolveRange } from './resolveRange'
-import dlv from 'dlv'
-import { rangesEqual } from './rangesEqual'
 import Regex from 'becke-ch--regex--s0-0-v1--base--pl--lib'
 import { getTextWithoutComments } from './doc'
 
@@ -283,14 +281,6 @@   return result
 }
 
 import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
-import { isWithinRange } from './isWithinRange'
-  return classLists.filter(
-    (classList, classListIndex) =>
-      classListIndex === classLists.findIndex((c) => rangesEqual(c.range, classList.range))
-  )
-}
-
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
 import { getLanguageBoundaries } from './getLanguageBoundaries'
   state: State,
   doc: TextDocument,
@@ -305,7 +295,7 @@   } else {
     classLists = await findClassListsInHtmlRange(state, doc, mode, range)
   }
 import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
-import type { TextDocument, Range, Position } from 'vscode-languageserver'
+import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers'
 import { isWithinRange } from './isWithinRange'
     ...classLists,
     ...(includeCustom ? await findCustomClassLists(state, doc, range) : []),
@@ -324,7 +314,7 @@   let boundaries = getLanguageBoundaries(state, doc)
   if (!boundaries) return []
 
 import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
-export function findLast(re: RegExp, str: string): RegExpMatchArray {
+  })
     flatten([
       ...(await Promise.all(
         boundaries