@@ -168,36 +168,40 @@ async function provideSourceGlobHover(
168
168
169
169
let text = getTextWithoutComments ( document , 'css' , range )
170
170
171
- let pattern = / @ s o u r c e (?: \s + n o t ) ? \s * (?< path > ' [ ^ ' ] + ' | " [ ^ " ] + " ) / dg
171
+ let patterns = [
172
+ / @ s o u r c e (?: \s + n o t ) ? \s * (?< glob > ' [ ^ ' ] + ' | " [ ^ " ] + " ) / dg,
173
+ ]
172
174
173
- for ( let match of findAll ( pattern , text ) ) {
174
- let path = match . groups . path . slice ( 1 , - 1 )
175
+ let matches = patterns . flatMap ( ( pattern ) => findAll ( pattern , text ) )
175
176
176
- // Ignore paths that don't need brace expansion
177
- if ( ! path . includes ( '{' ) || ! path . includes ( '}' ) ) continue
177
+ for ( let match of matches ) {
178
+ let glob = match . groups . glob . slice ( 1 , - 1 )
179
+
180
+ // Ignore globs that don't need brace expansion
181
+ if ( ! glob . includes ( '{' ) || ! glob . includes ( '}' ) ) continue
178
182
179
- // Ignore paths that don't contain the current position
183
+ // Ignore glob that don't contain the current position
180
184
let slice : Range = absoluteRange (
181
185
{
182
- start : indexToPosition ( text , match . indices . groups . path [ 0 ] ) ,
183
- end : indexToPosition ( text , match . indices . groups . path [ 1 ] ) ,
186
+ start : indexToPosition ( text , match . indices . groups . glob [ 0 ] ) ,
187
+ end : indexToPosition ( text , match . indices . groups . glob [ 1 ] ) ,
184
188
} ,
185
189
range ,
186
190
)
187
191
188
192
if ( ! isWithinRange ( position , slice ) ) continue
189
193
190
194
// Perform brace expansion
191
- let paths = new Set ( braces . expand ( path ) )
192
- if ( paths . size < 2 ) continue
195
+ let expanded = new Set ( braces . expand ( glob ) )
196
+ if ( expanded . size < 2 ) continue
193
197
194
198
return {
195
199
range : slice ,
196
200
contents : markdown ( [
197
201
//
198
202
'**Expansion**' ,
199
203
'```plaintext' ,
200
- ...Array . from ( paths , ( path ) => `- ${ path } ` ) ,
204
+ ...Array . from ( expanded , ( entry ) => `- ${ entry } ` ) ,
201
205
'```' ,
202
206
] ) ,
203
207
}
0 commit comments