tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Signature
-----BEGIN PGP SIGNATURE-----
wsBcBAABCAAQBQJixaztCRBK7hj4Ov3rIwAADLwIAFzpNG7hB/qmH9qBDZ7fnd4N
XiPOd/sqGW/iD3htqaKH0Bz1XilUmcnuVAl2YeAplo2I+OzLgK8KB4SRUYPPd1u8
wQ73U6XWjMJ0JZg8zS1pjiRptbVEZt1ykkqneW7bAx5ay9blhDyJ/O3di16JuWy4
RD1ZBTDU4mqomzejSxMZIWYRnsXE9eF2DmcpIcbHnsUXWLa3Ji8Y7EZy7/u2W2b3
3TSE3sKn65LNLxLNTQx16rffe8UgVWICnIa7K4txFAntsL7h53P5SJrB5KR9LV9a
RZSNr6ZZNrHFuHGxgTOIQQpWs2bCcoV13TbKerE/6MrA0mEzlrk+rRKG7F2b8/g=
=k5Aj
-----END PGP SIGNATURE-----
diff --git a/packages/tailwindcss-language-service/src/util/find.ts b/packages/tailwindcss-language-service/src/util/find.ts
index 299f777cd3952b8bbe3e3d0b4c239e354101d340..b0a4196195b9ffc81ec093c325319bb1933704e1 100644
--- a/packages/tailwindcss-language-service/src/util/find.ts
+++ b/packages/tailwindcss-language-service/src/util/find.ts
@@ -11,6 +11,7 @@ import { getLanguageBoundaries } from './getLanguageBoundaries'
import { resolveRange } from './resolveRange'
import dlv from 'dlv'
import { createMultiRegexp } from './createMultiRegexp'
+import { rangesEqual } from './rangesEqual'
export function findAll(re: RegExp, str: string): RegExpMatchArray[] {
let match: RegExpMatchArray
@@ -277,6 +278,13 @@
return result
}
+function dedupeClassLists(classLists: DocumentClassList[]): DocumentClassList[] {
+ return classLists.filter(
+ (classList, classListIndex) =>
+ classListIndex === classLists.findIndex((c) => rangesEqual(c.range, classList.range))
+ )
+}
+
export async function findClassListsInRange(
state: State,
doc: TextDocument,
@@ -290,7 +298,10 @@ classLists = findClassListsInCssRange(doc, range)
} else {
classLists = await findClassListsInHtmlRange(state, doc, range)
}
- return [...classLists, ...(includeCustom ? await findCustomClassLists(state, doc, range) : [])]
+ return dedupeClassLists([
+ ...classLists,
+ ...(includeCustom ? await findCustomClassLists(state, doc, range) : []),
+ ])
}
export async function findClassListsInDocument(
@@ -304,17 +315,19 @@
let boundaries = getLanguageBoundaries(state, doc)
if (!boundaries) return []
- return flatten([
- ...(await Promise.all(
- boundaries
- .filter((b) => b.type === 'html' || b.type === 'jsx')
- .map(({ range }) => findClassListsInHtmlRange(state, doc, range))
- )),
- ...boundaries
- .filter((b) => b.type === 'css')
- .map(({ range }) => findClassListsInCssRange(doc, range)),
- await findCustomClassLists(state, doc),
- ])
+ return dedupeClassLists(
+ flatten([
+ ...(await Promise.all(
+ boundaries
+ .filter((b) => b.type === 'html' || b.type === 'jsx')
+ .map(({ range }) => findClassListsInHtmlRange(state, doc, range))
+ )),
+ ...boundaries
+ .filter((b) => b.type === 'css')
+ .map(({ range }) => findClassListsInCssRange(doc, range)),
+ await findCustomClassLists(state, doc),
+ ])
+ )
}
export function findHelperFunctionsInDocument(
diff --git a/packages/tailwindcss-language-service/src/util/rangesEqual.ts b/packages/tailwindcss-language-service/src/util/rangesEqual.ts
index 220cebd50e242933d666ee7581d68e4030dd321b..0d9665521a801356c3689a4882bc182b3bd4f7da 100644
--- a/packages/tailwindcss-language-service/src/util/rangesEqual.ts
+++ b/packages/tailwindcss-language-service/src/util/rangesEqual.ts
@@ -1,4 +1,4 @@
-import { Range } from 'vscode-languageserver'
+import type { Range } from 'vscode-languageserver'
export function rangesEqual(a: Range, b: Range): boolean {
return (