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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
diff --git a/packages/tailwindcss-language-service/src/completionProvider.ts b/packages/tailwindcss-language-service/src/completionProvider.ts
index 0ca4912421f22290fee572e99e5184bc34314bb8..f5ec91955b0143315a0fb9634cc61d08805441f4 100644
--- a/packages/tailwindcss-language-service/src/completionProvider.ts
+++ b/packages/tailwindcss-language-service/src/completionProvider.ts
@@ -44,7 +44,6 @@ state: State,
classList: string,
classListRange: Range,
filter?: (item: CompletionItem) => boolean,
- document?: TextDocument,
context?: CompletionContext
): CompletionList {
let classNames = classList.split(/[\s+]/)
@@ -464,7 +463,6 @@ },
end: position,
},
undefined,
- document,
context
)
}
@@ -476,7 +474,8 @@
async function provideCustomClassNameCompletions(
state: State,
document: TextDocument,
- position: Position
+ position: Position,
+ context?: CompletionContext
): Promise<CompletionList> {
const settings = await state.editor.getConfiguration(document.uri)
const regexes = settings.tailwindCSS.experimental.classRegex
@@ -527,13 +526,19 @@ } else {
classList = containerMatch[1].substr(0, cursor - matchStart)
}
- return completionsFromClassList(state, classList, {
- start: {
- line: position.line,
- character: position.character - classList.length,
+ return completionsFromClassList(
+ state,
+ classList,
+ {
+ start: {
+ line: position.line,
+ character: position.character - classList.length,
+ },
+ end: position,
},
- end: position,
- })
+ undefined,
+ context
+ )
}
}
} catch (_) {}
@@ -545,7 +550,8 @@
function provideAtApplyCompletions(
state: State,
document: TextDocument,
- position: Position
+ position: Position,
+ context?: CompletionContext
): CompletionList {
let str = document.getText({
start: { line: Math.max(position.line - 30, 0), character: 0 },
@@ -580,7 +586,8 @@ let variants = item.data?.variants ?? []
let className = item.data?.className ?? item.label
let validated = validateApply(state, [...variants, className])
return validated !== null && validated.isApplyable === true
- }
+ },
+ context
)
}
@@ -596,7 +603,7 @@ position: Position,
context?: CompletionContext
): Promise<CompletionList> {
if (isCssContext(state, document, position)) {
- return provideAtApplyCompletions(state, document, position)
+ return provideAtApplyCompletions(state, document, position, context)
}
if (isHtmlContext(state, document, position) || isJsxContext(state, document, position)) {
@@ -1329,7 +1336,7 @@ provideVariantsDirectiveCompletions(state, document, position) ||
provideTailwindDirectiveCompletions(state, document, position) ||
provideLayerDirectiveCompletions(state, document, position) ||
(await provideConfigDirectiveCompletions(state, document, position)) ||
- (await provideCustomClassNameCompletions(state, document, position))
+ (await provideCustomClassNameCompletions(state, document, position, context))
if (result) return result
|