@@ -30,9 +30,9 @@ import {
30
30
isWindows
31
31
} from '@theia/core/lib/common' ;
32
32
import {
33
- ApplicationShell , KeybindingContribution , KeyCode , Key , WidgetManager ,
33
+ ApplicationShell , KeybindingContribution , KeyCode , Key , WidgetManager , PreferenceService ,
34
34
KeybindingRegistry , Widget , LabelProvider , WidgetOpenerOptions , StorageService ,
35
- QuickInputService , codicon , CommonCommands , FrontendApplicationContribution , OnWillStopAction , Dialog , ConfirmDialog , FrontendApplication
35
+ QuickInputService , codicon , CommonCommands , FrontendApplicationContribution , OnWillStopAction , Dialog , ConfirmDialog , FrontendApplication , PreferenceScope
36
36
} from '@theia/core/lib/browser' ;
37
37
import { TabBarToolbarContribution , TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar' ;
38
38
import { TERMINAL_WIDGET_FACTORY_ID , TerminalWidgetFactoryOptions , TerminalWidgetImpl } from './terminal-widget-impl' ;
@@ -198,6 +198,9 @@ export class TerminalFrontendContribution implements FrontendApplicationContribu
198
198
@inject ( StorageService )
199
199
protected readonly storageService : StorageService ;
200
200
201
+ @inject ( PreferenceService )
202
+ protected readonly preferenceService : PreferenceService ;
203
+
201
204
@inject ( TerminalPreferences )
202
205
protected terminalPreferences : TerminalPreferences ;
203
206
@@ -245,9 +248,31 @@ export class TerminalFrontendContribution implements FrontendApplicationContribu
245
248
await this . contributeDefaultProfiles ( ) ;
246
249
247
250
this . terminalPreferences . onPreferenceChanged ( e => {
248
- this . mergePreferencesPromise = this . mergePreferencesPromise . finally ( ( ) => this . mergePreferences ( ) ) ;
251
+ if ( e . preferenceName . startsWith ( 'terminal.integrated.' ) ) {
252
+ this . mergePreferencesPromise = this . mergePreferencesPromise . finally ( ( ) => this . mergePreferences ( ) ) ;
253
+ }
249
254
} ) ;
250
255
this . mergePreferencesPromise = this . mergePreferencesPromise . finally ( ( ) => this . mergePreferences ( ) ) ;
256
+
257
+ this . profileService . onAdded ( id => {
258
+ // extension contributions get read after this point: need to set the default profile if necessary
259
+ let defaultProfileId ;
260
+ switch ( OS . type ( ) ) {
261
+ case OS . Type . Windows : {
262
+ defaultProfileId = this . terminalPreferences [ 'terminal.integrated.defaultProfile.windows' ] ;
263
+ break ;
264
+ }
265
+ case OS . Type . Linux : {
266
+ defaultProfileId = this . terminalPreferences [ 'terminal.integrated.defaultProfile.linux' ] ;
267
+ break ;
268
+ }
269
+ case OS . Type . OSX : {
270
+ defaultProfileId = this . terminalPreferences [ 'terminal.integrated.defaultProfile.osx' ] ;
271
+ break ;
272
+ }
273
+ }
274
+ this . profileService . setDefaultProfile ( defaultProfileId ) ;
275
+ } ) ;
251
276
}
252
277
253
278
async contributeDefaultProfiles ( ) : Promise < void > {
@@ -259,7 +284,7 @@ export class TerminalFrontendContribution implements FrontendApplicationContribu
259
284
] ) !
260
285
} ) ) ;
261
286
} else {
262
- this . contributedProfileStore . registerTerminalProfile ( 'cmd ' , new ShellTerminalProfile ( this , {
287
+ this . contributedProfileStore . registerTerminalProfile ( 'SHELL ' , new ShellTerminalProfile ( this , {
263
288
shellPath : await this . resolveShellPath ( '${SHELL}' ) ! ,
264
289
shellArgs : [ '-l' ]
265
290
} ) ) ;
@@ -916,7 +941,7 @@ export class TerminalFrontendContribution implements FrontendApplicationContribu
916
941
return ;
917
942
}
918
943
919
- this . profileService . setDefaultProfile ( result [ 0 ] ) ;
944
+ this . preferenceService . set ( `terminal.integrated.defaultProfile. ${ OS . type ( ) . toLowerCase ( ) } ` , result [ 0 ] , PreferenceScope . User ) ;
920
945
}
921
946
922
947
protected async openActiveWorkspaceTerminal ( options ?: ApplicationShell . WidgetOptions ) : Promise < void > {
0 commit comments