File tree Expand file tree Collapse file tree 3 files changed +83
-0
lines changed
tailwindcss-language-service/src/util Expand file tree Collapse file tree 3 files changed +83
-0
lines changed Original file line number Diff line number Diff line change 1+ import type { State } from './state'
2+ import { test } from 'vitest'
3+ import { TextDocument } from 'vscode-languageserver-textdocument'
4+ import { findClassListsInHtmlRange } from './find'
5+
6+ test ( 'test' , async ( { expect } ) => {
7+ let content = [
8+ //
9+ '<a class=`p-4 sm:p-2 ${active ? "underline": "line-through"}`>' ,
10+ ' <slot />' ,
11+ '</a>' ,
12+ ] . join ( '\n' )
13+
14+ let doc = TextDocument . create ( 'file://file.astro' , 'astro' , 1 , content )
15+ let state : State = {
16+ blocklist : [ ] ,
17+ editor : {
18+ userLanguages : { } ,
19+ getConfiguration : async ( ) => ( {
20+ editor : {
21+ tabSize : 1 ,
22+ } ,
23+ tailwindCSS : {
24+ classAttributes : [ 'class' ] ,
25+ experimental : {
26+ classRegex : [
27+ [ 'cva\\(([^)]*)\\)' , '["\'`]([^"\'`]*).*?["\'`]' ] ,
28+ [ 'cn\\(([^)]*)\\)' , '["\'`]([^"\'`]*).*?["\'`]' ] ,
29+ ] ,
30+ } ,
31+ } as any ,
32+ } ) ,
33+ } as any ,
34+ } as any
35+
36+ let classLists = await findClassListsInHtmlRange ( state , doc , 'html' )
37+
38+ expect ( classLists ) . toMatchInlineSnapshot ( `
39+ [
40+ {
41+ "classList": "p-4 sm:p-2 $",
42+ "range": {
43+ "end": {
44+ "character": 22,
45+ "line": 0,
46+ },
47+ "start": {
48+ "character": 10,
49+ "line": 0,
50+ },
51+ },
52+ },
53+ {
54+ "classList": "underline",
55+ "range": {
56+ "end": {
57+ "character": 42,
58+ "line": 0,
59+ },
60+ "start": {
61+ "character": 33,
62+ "line": 0,
63+ },
64+ },
65+ },
66+ {
67+ "classList": "line-through",
68+ "range": {
69+ "end": {
70+ "character": 58,
71+ "line": 0,
72+ },
73+ "start": {
74+ "character": 46,
75+ "line": 0,
76+ },
77+ },
78+ },
79+ ]
80+ ` )
81+ } )
Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ export const getClassAttributeLexer = lazy(() => {
7272 start1 : { match : '"' , push : 'doubleClassList' } ,
7373 start2 : { match : "'" , push : 'singleClassList' } ,
7474 start3 : { match : '{' , push : 'interpBrace' } ,
75+ start4 : { match : '`' , push : 'tickClassList' } ,
7576 } ,
7677 ...classAttributeStates ( ) ,
7778 } )
Original file line number Diff line number Diff line change 1212- Assume 16px font size for ` 1rem ` in media queries ([ #1190 ] ( https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1190 ) )
1313- Show warning when loading a config in v3 fails ([ #1191 ] ( https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1191 ) )
1414- Better handle really long class lists in attributes and custom regexes ([ #1192 ] ( https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1192 ) )
15+ - Add support for Astro’s template literal attributes ([ #1193 ] ( https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1193 ) )
1516
1617## 0.14.3
1718
You can’t perform that action at this time.
0 commit comments