11import { Autowired , Injectable } from '@opensumi/di' ;
2+ import { getExternalIcon } from '@opensumi/ide-core-browser' ;
23import { IQuickPickItemButtonEvent , QuickInputButton } from '@opensumi/ide-core-browser/lib/quick-open' ;
34import { StaticResourceService } from '@opensumi/ide-core-browser/lib/static-resource' ;
4- import { Emitter , Event } from '@opensumi/ide-core-common' ;
5+ import { Emitter , Event , ThemeIcon , URI } from '@opensumi/ide-core-common' ;
56import { IIconService , IThemeService , IconType } from '@opensumi/ide-theme' ;
67
78import { iconPath2URI } from '../common/icon' ;
@@ -35,7 +36,18 @@ export class QuickOpenItemService {
3536 return [ ] ;
3637 }
3738 return buttons . map ( ( btn , i ) => {
38- const iconUri = iconPath2URI ( btn . iconPath , this . themeService . getCurrentThemeSync ( ) . type ) ;
39+ if ( ThemeIcon . isThemeIcon ( btn . iconPath ) ) {
40+ return {
41+ ...btn ,
42+ iconClass : getExternalIcon ( btn . iconPath . id ) ,
43+ handle : i ,
44+ } ;
45+ }
46+
47+ const iconUri = iconPath2URI (
48+ btn . iconPath as URI | { light : URI ; dark : URI } ,
49+ this . themeService . getCurrentThemeSync ( ) . type ,
50+ ) ;
3951 const iconPath = iconUri && this . staticResourceService . resolveStaticResource ( iconUri ) . toString ( ) ;
4052 const iconClass = iconPath && this . iconService . fromIcon ( '' , iconPath , IconType . Background ) ;
4153 return {
@@ -45,4 +57,26 @@ export class QuickOpenItemService {
4557 } ;
4658 } ) ;
4759 }
60+
61+ getIconClass ( data : { iconPath ?: URI | { light : URI ; dark : URI } | ThemeIcon ; iconClass ?: string } ) {
62+ const { iconClass, iconPath } = data ;
63+
64+ if ( iconClass ) {
65+ return iconClass ;
66+ }
67+
68+ if ( ! iconPath ) {
69+ return undefined ;
70+ }
71+
72+ if ( ThemeIcon . isThemeIcon ( iconPath ) ) {
73+ return getExternalIcon ( iconPath . id ) ;
74+ }
75+
76+ const iconUri = iconPath2URI ( iconPath , this . themeService . getCurrentThemeSync ( ) . type ) ;
77+ const iconPathString = iconUri && this . staticResourceService . resolveStaticResource ( iconUri ) . toString ( ) ;
78+ const iconCls = iconPath && this . iconService . fromIcon ( '' , iconPathString , IconType . Background ) ;
79+
80+ return iconCls ;
81+ }
4882}
0 commit comments