@@ -30,9 +30,9 @@ import {
3030 isWindows
3131} from '@theia/core/lib/common' ;
3232import {
33- ApplicationShell , KeybindingContribution , KeyCode , Key , WidgetManager ,
33+ ApplicationShell , KeybindingContribution , KeyCode , Key , WidgetManager , PreferenceService ,
3434 KeybindingRegistry , Widget , LabelProvider , WidgetOpenerOptions , StorageService ,
35- QuickInputService , codicon , CommonCommands , FrontendApplicationContribution , OnWillStopAction , Dialog , ConfirmDialog , FrontendApplication
35+ QuickInputService , codicon , CommonCommands , FrontendApplicationContribution , OnWillStopAction , Dialog , ConfirmDialog , FrontendApplication , PreferenceScope
3636} from '@theia/core/lib/browser' ;
3737import { TabBarToolbarContribution , TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar' ;
3838import { TERMINAL_WIDGET_FACTORY_ID , TerminalWidgetFactoryOptions , TerminalWidgetImpl } from './terminal-widget-impl' ;
@@ -198,6 +198,9 @@ export class TerminalFrontendContribution implements FrontendApplicationContribu
198198 @inject ( StorageService )
199199 protected readonly storageService : StorageService ;
200200
201+ @inject ( PreferenceService )
202+ protected readonly preferenceService : PreferenceService ;
203+
201204 @inject ( TerminalPreferences )
202205 protected terminalPreferences : TerminalPreferences ;
203206
@@ -245,9 +248,31 @@ export class TerminalFrontendContribution implements FrontendApplicationContribu
245248 await this . contributeDefaultProfiles ( ) ;
246249
247250 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+ }
249254 } ) ;
250255 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+ } ) ;
251276 }
252277
253278 async contributeDefaultProfiles ( ) : Promise < void > {
@@ -259,7 +284,7 @@ export class TerminalFrontendContribution implements FrontendApplicationContribu
259284 ] ) !
260285 } ) ) ;
261286 } else {
262- this . contributedProfileStore . registerTerminalProfile ( 'cmd ' , new ShellTerminalProfile ( this , {
287+ this . contributedProfileStore . registerTerminalProfile ( 'SHELL ' , new ShellTerminalProfile ( this , {
263288 shellPath : await this . resolveShellPath ( '${SHELL}' ) ! ,
264289 shellArgs : [ '-l' ]
265290 } ) ) ;
@@ -916,7 +941,7 @@ export class TerminalFrontendContribution implements FrontendApplicationContribu
916941 return ;
917942 }
918943
919- this . profileService . setDefaultProfile ( result [ 0 ] ) ;
944+ this . preferenceService . set ( `terminal.integrated.defaultProfile. ${ OS . type ( ) . toLowerCase ( ) } ` , result [ 0 ] , PreferenceScope . User ) ;
920945 }
921946
922947 protected async openActiveWorkspaceTerminal ( options ?: ApplicationShell . WidgetOptions ) : Promise < void > {
0 commit comments