@@ -11,6 +11,7 @@ import { getLanguageBoundaries } from './getLanguageBoundaries'
11
11
import { resolveRange } from './resolveRange'
12
12
import Regex from 'becke-ch--regex--s0-0-v1--base--pl--lib'
13
13
import { getTextWithoutComments } from './doc'
14
+ import { isSemicolonlessCssLanguage } from './languages'
14
15
15
16
export function findAll ( re : RegExp , str : string ) : RegExpMatchArray [ ] {
16
17
let match : RegExpMatchArray
@@ -91,12 +92,16 @@ export async function findClassNamesInDocument(
91
92
)
92
93
}
93
94
94
- export function findClassListsInCssRange ( doc : TextDocument , range ?: Range ) : DocumentClassList [ ] {
95
+ export function findClassListsInCssRange (
96
+ state : State ,
97
+ doc : TextDocument ,
98
+ range ?: Range
99
+ ) : DocumentClassList [ ] {
95
100
const text = getTextWithoutComments ( doc , 'css' , range )
96
- const matches = findAll (
97
- / ( @ a p p l y \s + ) (?< classList > [ ^ ; } ] + ?) (?< important > \s * ! i m p o r t a n t ) ? \s * [ ; } ] / g ,
98
- text
99
- )
101
+ let regex = isSemicolonlessCssLanguage ( doc . languageId , state . editor ?. userLanguages )
102
+ ? / ( @ a p p l y \s + ) (?< classList > [ ^ } \r \n ] + ?) (?< important > \s * ! i m p o r t a n t ) ? (?: \r | \n | } | $ ) / g
103
+ : / ( @ a p p l y \s + ) (?< classList > [ ^ ; } ] + ? ) (?< important > \s * ! i m p o r t a n t ) ? \s * [ ; } ] / g
104
+ const matches = findAll ( regex , text )
100
105
const globalStart : Position = range ? range . start : { line : 0 , character : 0 }
101
106
102
107
return matches . map ( ( match ) => {
@@ -292,7 +297,7 @@ export async function findClassListsInRange(
292
297
) : Promise < DocumentClassList [ ] > {
293
298
let classLists : DocumentClassList [ ]
294
299
if ( mode === 'css' ) {
295
- classLists = findClassListsInCssRange ( doc , range )
300
+ classLists = findClassListsInCssRange ( state , doc , range )
296
301
} else {
297
302
classLists = await findClassListsInHtmlRange ( state , doc , mode , range )
298
303
}
@@ -307,7 +312,7 @@ export async function findClassListsInDocument(
307
312
doc : TextDocument
308
313
) : Promise < DocumentClassList [ ] > {
309
314
if ( isCssDoc ( state , doc ) ) {
310
- return findClassListsInCssRange ( doc )
315
+ return findClassListsInCssRange ( state , doc )
311
316
}
312
317
313
318
let boundaries = getLanguageBoundaries ( state , doc )
@@ -324,7 +329,7 @@ export async function findClassListsInDocument(
324
329
) ) ,
325
330
...boundaries
326
331
. filter ( ( b ) => b . type === 'css' )
327
- . map ( ( { range } ) => findClassListsInCssRange ( doc , range ) ) ,
332
+ . map ( ( { range } ) => findClassListsInCssRange ( state , doc , range ) ) ,
328
333
await findCustomClassLists ( state , doc ) ,
329
334
] )
330
335
)
0 commit comments