1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
diff --git a/packages/tailwindcss-language-service/src/util/find.ts b/packages/tailwindcss-language-service/src/util/find.ts
index 1977ef89a20f15fb0a736b7aae346804e1048b42..f9ffd20b20d329105861972a4916ba75d776a324 100644
--- a/packages/tailwindcss-language-service/src/util/find.ts
+++ b/packages/tailwindcss-language-service/src/util/find.ts
@@ -29,16 +29,15 @@ }
return matches[matches.length - 1]
}
-export function getClassNamesInClassList({
- classList,
- range,
- important,
-}: DocumentClassList): DocumentClassName[] {
+export function getClassNamesInClassList(
+ { classList, range, important }: DocumentClassList,
+ blocklist: State['blocklist']
+): DocumentClassName[] {
const parts = classList.split(/(\s+)/)
const names: DocumentClassName[] = []
let index = 0
for (let i = 0; i < parts.length; i++) {
- if (i % 2 === 0) {
+ if (i % 2 === 0 && !blocklist.includes(parts[i])) {
const start = indexToPosition(classList, index)
const end = indexToPosition(classList, index + parts[i].length)
names.push({
@@ -77,7 +76,9 @@ mode?: 'html' | 'css' | 'jsx',
includeCustom: boolean = true
): Promise<DocumentClassName[]> {
const classLists = await findClassListsInRange(state, doc, range, mode, includeCustom)
- return flatten(classLists.map(getClassNamesInClassList))
+ return flatten(
+ classLists.map((classList) => getClassNamesInClassList(classList, state.blocklist))
+ )
}
export async function findClassNamesInDocument(
@@ -85,7 +86,9 @@ state: State,
doc: TextDocument
): Promise<DocumentClassName[]> {
const classLists = await findClassListsInDocument(state, doc)
- return flatten(classLists.map(getClassNamesInClassList))
+ return flatten(
+ classLists.map((classList) => getClassNamesInClassList(classList, state.blocklist))
+ )
}
export function findClassListsInCssRange(doc: TextDocument, range?: Range): DocumentClassList[] {
|