@@ -525,17 +525,22 @@ class TextEditElementTemplate {
525525 private readonly _localDisposables = new DisposableStore ( ) ;
526526
527527 private readonly _checkbox : HTMLInputElement ;
528+ private readonly _icon : HTMLDivElement ;
528529 private readonly _label : HighlightedLabel ;
529530
530531 constructor ( container : HTMLElement ) {
532+ container . classList . add ( 'textedit' ) ;
533+
531534 this . _checkbox = document . createElement ( 'input' ) ;
532535 this . _checkbox . className = 'edit-checkbox' ;
533536 this . _checkbox . type = 'checkbox' ;
534537 this . _checkbox . setAttribute ( 'role' , 'checkbox' ) ;
535538 container . appendChild ( this . _checkbox ) ;
536539
540+ this . _icon = document . createElement ( 'div' ) ;
541+ container . appendChild ( this . _icon ) ;
542+
537543 this . _label = new HighlightedLabel ( container , false ) ;
538- dom . addClass ( this . _label . element , 'textedit' ) ;
539544 }
540545
541546 dispose ( ) : void {
@@ -575,7 +580,36 @@ class TextEditElementTemplate {
575580 title = metadata . label ;
576581 }
577582
583+ const iconPath = metadata ?. iconPath ;
584+ if ( ! iconPath ) {
585+ this . _icon . style . display = 'none' ;
586+ } else {
587+ this . _icon . style . display = 'block' ;
588+
589+ this . _icon . style . setProperty ( '--background-dark' , null ) ;
590+ this . _icon . style . setProperty ( '--background-light' , null ) ;
591+
592+ if ( ThemeIcon . isThemeIcon ( iconPath ) ) {
593+ // css
594+ const className = ThemeIcon . asClassName ( iconPath ) ;
595+ this . _icon . className = className ? `theme-icon ${ className } ` : '' ;
596+
597+ } else if ( URI . isUri ( iconPath ) ) {
598+ // background-image
599+ this . _icon . className = 'uri-icon' ;
600+ this . _icon . style . setProperty ( '--background-dark' , `url("${ iconPath . toString ( true ) } ")` ) ;
601+ this . _icon . style . setProperty ( '--background-light' , `url("${ iconPath . toString ( true ) } ")` ) ;
602+
603+ } else {
604+ // background-image
605+ this . _icon . className = 'uri-icon' ;
606+ this . _icon . style . setProperty ( '--background-dark' , `url("${ iconPath . dark . toString ( true ) } ")` ) ;
607+ this . _icon . style . setProperty ( '--background-light' , `url("${ iconPath . light . toString ( true ) } ")` ) ;
608+ }
609+ }
610+
578611 this . _label . set ( value , [ selectHighlight , insertHighlight ] , title , true ) ;
612+ this . _icon . title = title || '' ;
579613 }
580614}
581615
0 commit comments