@@ -569,7 +569,7 @@ function provideCssHelperCompletions(
569
569
}
570
570
571
571
let obj : any
572
- let offset : number = 0
572
+ let offset : number = keys [ keys . length - 1 ] . length
573
573
let separator : string = separators . length ? separators [ separators . length - 1 ] : null
574
574
575
575
if ( keys . length === 1 ) {
@@ -588,6 +588,14 @@ function provideCssHelperCompletions(
588
588
589
589
if ( ! obj ) return null
590
590
591
+ let editRange = {
592
+ start : {
593
+ line : position . line ,
594
+ character : position . character - offset ,
595
+ } ,
596
+ end : position ,
597
+ }
598
+
591
599
return {
592
600
isIncomplete : false ,
593
601
items : Object . keys ( obj ) . map ( ( item , index ) => {
@@ -600,8 +608,8 @@ function provideCssHelperCompletions(
600
608
601
609
return {
602
610
label : item ,
603
- filterText : `${ replaceDot ? '.' : '' } ${ item } ` ,
604
611
sortText : naturalExpand ( index ) ,
612
+ commitCharacters : [ ! item . includes ( '.' ) && '.' , ! item . includes ( '[' ) && '[' ] . filter ( Boolean ) ,
605
613
kind : color ? 16 : isObject ( obj [ item ] ) ? 9 : 10 ,
606
614
// VS Code bug causes some values to not display in some cases
607
615
detail : detail === '0' || detail === 'transparent' ? `${ detail } ` : detail ,
@@ -610,16 +618,23 @@ function provideCssHelperCompletions(
610
618
? culori . formatRgb ( color )
611
619
: null ,
612
620
textEdit : {
613
- newText : `${ replaceDot ? '[' : '' } ${ item } ${ insertClosingBrace ? ']' : '' } ` ,
614
- range : {
615
- start : {
616
- line : position . line ,
617
- character :
618
- position . character - keys [ keys . length - 1 ] . length - ( replaceDot ? 1 : 0 ) - offset ,
619
- } ,
620
- end : position ,
621
- } ,
621
+ newText : `${ item } ${ insertClosingBrace ? ']' : '' } ` ,
622
+ range : editRange ,
622
623
} ,
624
+ additionalTextEdits : replaceDot
625
+ ? [
626
+ {
627
+ newText : '[' ,
628
+ range : {
629
+ start : {
630
+ ...editRange . start ,
631
+ character : editRange . start . character - 1 ,
632
+ } ,
633
+ end : editRange . start ,
634
+ } ,
635
+ } ,
636
+ ]
637
+ : [ ] ,
623
638
data : 'helper' ,
624
639
}
625
640
} ) ,
0 commit comments