@@ -112,21 +112,30 @@ function createCompletionItemProvider(
112
112
document : vscode . TextDocument ,
113
113
position : vscode . Position
114
114
) : vscode . CompletionItem [ ] {
115
+ const separator = config . options . separator || ':'
116
+ let str
117
+
115
118
const range : vscode . Range = new vscode . Range (
116
119
new vscode . Position ( Math . max ( position . line - 5 , 0 ) , 0 ) ,
117
120
position
118
121
)
119
122
const text : string = document . getText ( range )
120
123
121
- let p = prefix
122
- const separator = config . options . separator || ':'
123
-
124
- const matches = text . match ( regex )
124
+ let matches = text . match ( regex )
125
125
126
126
if ( matches ) {
127
- const parts = matches [ matches . length - 1 ] . split ( ' ' )
128
- const str = parts [ parts . length - 1 ]
127
+ let parts = matches [ matches . length - 1 ] . split ( ' ' )
128
+ str = parts [ parts . length - 1 ]
129
+ } else if ( languages . indexOf ( 'html' ) !== - 1 ) {
130
+ // match emmet style syntax
131
+ // e.g. .flex.items-center
132
+ let lineText = text . split ( '\n' ) . pop ( )
133
+ matches = lineText . match ( / ^ \s * [ a - z - ] * \. ( .* ?) $ / i)
134
+ let parts = matches [ matches . length - 1 ] . split ( '.' )
135
+ str = parts [ parts . length - 1 ]
136
+ }
129
137
138
+ if ( typeof str !== 'undefined' ) {
130
139
const pth = str
131
140
. replace ( new RegExp ( `${ separator } ` , 'g' ) , '.' )
132
141
. replace ( / \. $ / , '' )
@@ -342,7 +351,7 @@ class TailwindIntellisense {
342
351
this . _items ,
343
352
HTML_TYPES ,
344
353
/ \b c l a s s ( N a m e ) ? = [ " ' ] ( [ ^ " ' ] * ) $ / , // /\bclass(Name)?=(["'])(?!.*?\2)/
345
- [ "'" , '"' , ' ' , separator ] ,
354
+ [ "'" , '"' , ' ' , '.' , separator ] ,
346
355
tailwind . config
347
356
)
348
357
)
0 commit comments