@@ -11,6 +11,7 @@ import { getLanguageBoundaries } from './getLanguageBoundaries'
1111import { resolveRange } from './resolveRange'
1212import Regex from 'becke-ch--regex--s0-0-v1--base--pl--lib'
1313import { getTextWithoutComments } from './doc'
14+ import { isSemicolonlessCssLanguage } from './languages'
1415
1516export function findAll ( re : RegExp , str : string ) : RegExpMatchArray [ ] {
1617 let match : RegExpMatchArray
@@ -91,12 +92,16 @@ export async function findClassNamesInDocument(
9192 )
9293}
9394
94- export function findClassListsInCssRange ( doc : TextDocument , range ?: Range ) : DocumentClassList [ ] {
95+ export function findClassListsInCssRange (
96+ state : State ,
97+ doc : TextDocument ,
98+ range ?: Range
99+ ) : DocumentClassList [ ] {
95100 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 )
100105 const globalStart : Position = range ? range . start : { line : 0 , character : 0 }
101106
102107 return matches . map ( ( match ) => {
@@ -292,7 +297,7 @@ export async function findClassListsInRange(
292297) : Promise < DocumentClassList [ ] > {
293298 let classLists : DocumentClassList [ ]
294299 if ( mode === 'css' ) {
295- classLists = findClassListsInCssRange ( doc , range )
300+ classLists = findClassListsInCssRange ( state , doc , range )
296301 } else {
297302 classLists = await findClassListsInHtmlRange ( state , doc , mode , range )
298303 }
@@ -307,7 +312,7 @@ export async function findClassListsInDocument(
307312 doc : TextDocument
308313) : Promise < DocumentClassList [ ] > {
309314 if ( isCssDoc ( state , doc ) ) {
310- return findClassListsInCssRange ( doc )
315+ return findClassListsInCssRange ( state , doc )
311316 }
312317
313318 let boundaries = getLanguageBoundaries ( state , doc )
@@ -324,7 +329,7 @@ export async function findClassListsInDocument(
324329 ) ) ,
325330 ...boundaries
326331 . filter ( ( b ) => b . type === 'css' )
327- . map ( ( { range } ) => findClassListsInCssRange ( doc , range ) ) ,
332+ . map ( ( { range } ) => findClassListsInCssRange ( state , doc , range ) ) ,
328333 await findCustomClassLists ( state , doc ) ,
329334 ] )
330335 )
0 commit comments