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
|
diff --git a/packages/tailwindcss-language-service/src/util/getLanguageBoundaries.ts b/packages/tailwindcss-language-service/src/util/getLanguageBoundaries.ts
index bbe36ba68d407ebe4460cbf9095b9d689d148d17..a01a34ed97ac29898eaa1f687f07093ceca24f26 100644
--- a/packages/tailwindcss-language-service/src/util/getLanguageBoundaries.ts
+++ b/packages/tailwindcss-language-service/src/util/getLanguageBoundaries.ts
@@ -81,6 +81,17 @@ ...text,
},
html: {
htmlBlockEnd: { match: '</template>', pop: 1 },
+ nestedBlockStart: { match: '<template', push: 'nestedBlock' },
+ ...text,
+ },
+ nestedBlock: {
+ nestedStart: { match: '>', next: 'nested' },
+ nestedBlockEnd: { match: '/>', pop: 1 },
+ ...text,
+ },
+ nested: {
+ nestedBlockEnd: { match: '</template>', pop: 1 },
+ nestedBlockStart: { match: '<template', push: 'nestedBlock' },
...text,
},
}
@@ -124,19 +135,21 @@ let offset = 0
try {
for (let token of lexer) {
- if (token.type.endsWith('BlockStart')) {
- let position = indexToPosition(text, offset)
- if (!boundaries[boundaries.length - 1].range.end) {
+ if (!token.type.startsWith('nested')) {
+ if (token.type.endsWith('BlockStart')) {
+ let position = indexToPosition(text, offset)
+ if (!boundaries[boundaries.length - 1].range.end) {
+ boundaries[boundaries.length - 1].range.end = position
+ }
+ type = token.type.replace(/BlockStart$/, '')
+ boundaries.push({ type, range: { start: position, end: undefined } })
+ } else if (token.type.endsWith('BlockEnd')) {
+ let position = indexToPosition(text, offset)
boundaries[boundaries.length - 1].range.end = position
+ boundaries.push({ type: defaultType, range: { start: position, end: undefined } })
+ } else if (token.type === 'lang') {
+ boundaries[boundaries.length - 1].type = token.text
}
- type = token.type.replace(/BlockStart$/, '')
- boundaries.push({ type, range: { start: position, end: undefined } })
- } else if (token.type.endsWith('BlockEnd')) {
- let position = indexToPosition(text, offset)
- boundaries[boundaries.length - 1].range.end = position
- boundaries.push({ type: defaultType, range: { start: position, end: undefined } })
- } else if (token.type === 'lang') {
- boundaries[boundaries.length - 1].type = token.text
}
offset += token.text.length
}
|