@@ -15,11 +15,13 @@ import { IMessageService, Severity } from 'vs/platform/message/common/message';
1515import { Registry } from 'vs/platform/platform' ;
1616import { IWorkbenchActionRegistry , Extensions } from 'vs/workbench/common/actionRegistry' ;
1717import { IQuickOpenService , IPickOpenEntry } from 'vs/platform/quickOpen/common/quickOpen' ;
18- import { IThemeService } from 'vs/workbench/services/themes/common/themeService' ;
18+ import { IThemeService , COLOR_THEME_SETTING , ICON_THEME_SETTING } from 'vs/workbench/services/themes/common/themeService' ;
1919import { VIEWLET_ID , IExtensionsViewlet } from 'vs/workbench/parts/extensions/common/extensions' ;
2020import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement' ;
2121import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet' ;
2222import { Delayer } from 'vs/base/common/async' ;
23+ import { ConfigurationTarget } from 'vs/workbench/services/configuration/common/configurationEditing' ;
24+ import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration' ;
2325
2426export class SelectColorThemeAction extends Action {
2527
@@ -33,7 +35,8 @@ export class SelectColorThemeAction extends Action {
3335 @IMessageService private messageService : IMessageService ,
3436 @IThemeService private themeService : IThemeService ,
3537 @IExtensionGalleryService private extensionGalleryService : IExtensionGalleryService ,
36- @IViewletService private viewletService : IViewletService
38+ @IViewletService private viewletService : IViewletService ,
39+ @IWorkspaceConfigurationService private configurationService : IWorkspaceConfigurationService
3740 ) {
3841 super ( id , label ) ;
3942 }
@@ -48,12 +51,18 @@ export class SelectColorThemeAction extends Action {
4851 . map ( theme => ( { id : theme . id , label : theme . label , description : theme . description } ) )
4952 . sort ( ( t1 , t2 ) => t1 . label . localeCompare ( t2 . label ) ) ;
5053
51- const selectTheme = ( theme , broadcast ) => {
54+ const selectTheme = ( theme , applyTheme ) => {
5255 if ( theme === pickInMarketPlace ) {
5356 theme = currentTheme ;
5457 }
55- this . themeService . setColorTheme ( theme . id , broadcast )
56- . done ( null , err => this . messageService . show ( Severity . Info , localize ( 'problemChangingTheme' , "Problem loading theme: {0}" , err ) ) ) ;
58+ let target = null ;
59+ if ( applyTheme ) {
60+ let confValue = this . configurationService . lookup ( COLOR_THEME_SETTING ) ;
61+ target = typeof confValue . workspace !== 'undefined' ? ConfigurationTarget . WORKSPACE : ConfigurationTarget . USER ;
62+ }
63+
64+ this . themeService . setColorTheme ( theme . id , target )
65+ . done ( null , err => this . messageService . show ( Severity . Info , localize ( 'problemChangingTheme' , "Problem setting theme: {0}" , err ) ) ) ;
5766 } ;
5867
5968 const placeHolder = localize ( 'themes.selectTheme' , "Select Color Theme" ) ;
@@ -86,7 +95,9 @@ class SelectIconThemeAction extends Action {
8695 @IMessageService private messageService : IMessageService ,
8796 @IThemeService private themeService : IThemeService ,
8897 @IExtensionGalleryService private extensionGalleryService : IExtensionGalleryService ,
89- @IViewletService private viewletService : IViewletService
98+ @IViewletService private viewletService : IViewletService ,
99+ @IWorkspaceConfigurationService private configurationService : IWorkspaceConfigurationService
100+
90101 ) {
91102 super ( id , label ) ;
92103 }
@@ -103,12 +114,17 @@ class SelectIconThemeAction extends Action {
103114
104115 picks . splice ( 0 , 0 , { id : '' , label : localize ( 'noIconThemeLabel' , 'None' ) , description : localize ( 'noIconThemeDesc' , 'Disable file icons' ) } ) ;
105116
106- const selectTheme = ( theme , broadcast ) => {
117+ const selectTheme = ( theme , applyTheme ) => {
107118 if ( theme === pickInMarketPlace ) {
108119 theme = currentTheme ;
109120 }
110- this . themeService . setFileIconTheme ( theme && theme . id , broadcast )
111- . done ( null , err => this . messageService . show ( Severity . Info , localize ( 'problemChangingIconTheme' , "Problem loading icon theme: {0}" , err . message ) ) ) ;
121+ let target = null ;
122+ if ( applyTheme ) {
123+ let confValue = this . configurationService . lookup ( ICON_THEME_SETTING ) ;
124+ target = typeof confValue . workspace !== 'undefined' ? ConfigurationTarget . WORKSPACE : ConfigurationTarget . USER ;
125+ }
126+ this . themeService . setFileIconTheme ( theme && theme . id , target )
127+ . done ( null , err => this . messageService . show ( Severity . Info , localize ( 'problemChangingIconTheme' , "Problem setting icon theme: {0}" , err . message ) ) ) ;
112128 } ;
113129
114130 const placeHolder = localize ( 'themes.selectIconTheme' , "Select File Icon Theme" ) ;
0 commit comments