@@ -261,29 +261,25 @@ export function completionsFromClassList(
261
261
262
262
// TODO: This is a bit of a hack
263
263
if ( prefix . length > 0 ) {
264
- // No variants seen: suggest the prefix only
264
+ // No variants seen:
265
+ // - suggest the prefix as a variant
266
+ // - Modify the remaining items to include the prefix in the variant name
265
267
if ( existingVariants . length === 0 ) {
266
- items = items . slice ( 0 , 1 )
268
+ items = items . map ( ( item , idx ) => {
269
+ if ( idx === 0 ) return item
267
270
268
- return withDefaults (
269
- {
270
- isIncomplete : false ,
271
- items,
272
- } ,
273
- {
274
- data : {
275
- ...( state . completionItemData ?? { } ) ,
276
- ...( important ? { important } : { } ) ,
277
- variants : existingVariants ,
278
- } ,
279
- range : replacementRange ,
280
- } ,
281
- state . editor . capabilities . itemDefaults ,
282
- )
271
+ item . label = `${ prefix } :${ item . label } `
272
+
273
+ if ( item . textEditText ) {
274
+ item . textEditText = `${ prefix } :${ item . textEditText } `
275
+ }
276
+
277
+ return item
278
+ } )
283
279
}
284
280
285
281
// The first variant is not the prefix: don't suggest anything
286
- if ( existingVariants [ 0 ] !== prefix ) {
282
+ if ( existingVariants . length > 0 && existingVariants [ 0 ] !== prefix ) {
287
283
return null
288
284
}
289
285
}
@@ -304,6 +300,10 @@ export function completionsFromClassList(
304
300
documentation = formatColor ( color )
305
301
}
306
302
303
+ if ( prefix . length > 0 && existingVariants . length === 0 ) {
304
+ className = `${ prefix } :${ className } `
305
+ }
306
+
307
307
items . push ( {
308
308
label : className ,
309
309
kind,
0 commit comments