@@ -46,13 +46,15 @@ jsonRegistry.registerSchema(launchSchemaId, launchSchema);
4646
4747const DEBUG_SELECTED_CONFIG_NAME_KEY = 'debug.selectedconfigname' ;
4848const DEBUG_SELECTED_ROOT = 'debug.selectedroot' ;
49+ const DEBUG_SELECTED_CONFIG = 'debug.selectedconfig' ;
4950
5051export class ConfigurationManager implements IConfigurationManager {
5152 private debuggers : Debugger [ ] ;
5253 private breakpointModeIdsSet = new Set < string > ( ) ;
5354 private launches ! : ILaunch [ ] ;
5455 private selectedName : string | undefined ;
5556 private selectedLaunch : ILaunch | undefined ;
57+ private selectedConfig : IConfig | undefined ;
5658 private toDispose : IDisposable [ ] ;
5759 private readonly _onDidSelectConfigurationName = new Emitter < void > ( ) ;
5860 private configProviders : IDebugConfigurationProvider [ ] ;
@@ -82,10 +84,12 @@ export class ConfigurationManager implements IConfigurationManager {
8284 const previousSelectedRoot = this . storageService . get ( DEBUG_SELECTED_ROOT , StorageScope . WORKSPACE ) ;
8385 const previousSelectedLaunch = this . launches . find ( l => l . uri . toString ( ) === previousSelectedRoot ) ;
8486 this . debugConfigurationTypeContext = CONTEXT_DEBUG_CONFIGURATION_TYPE . bindTo ( contextKeyService ) ;
87+ const storedConfig = this . storageService . get ( DEBUG_SELECTED_CONFIG , StorageScope . WORKSPACE ) ;
88+ const selectedConfig = typeof storedConfig === 'string' ? JSON . parse ( storedConfig ) : undefined ;
8589 if ( previousSelectedLaunch && previousSelectedLaunch . getConfigurationNames ( ) . length ) {
86- this . selectConfiguration ( previousSelectedLaunch , this . storageService . get ( DEBUG_SELECTED_CONFIG_NAME_KEY , StorageScope . WORKSPACE ) ) ;
90+ this . selectConfiguration ( previousSelectedLaunch , this . storageService . get ( DEBUG_SELECTED_CONFIG_NAME_KEY , StorageScope . WORKSPACE ) , selectedConfig ) ;
8791 } else if ( this . launches . length > 0 ) {
88- this . selectConfiguration ( undefined ) ;
92+ this . selectConfiguration ( undefined , selectedConfig ? selectedConfig . name : undefined , selectedConfig ) ;
8993 }
9094 }
9195
@@ -434,10 +438,11 @@ export class ConfigurationManager implements IConfigurationManager {
434438 return this . launches . find ( l => l . workspace && l . workspace . uri . toString ( ) === workspaceUri . toString ( ) ) ;
435439 }
436440
437- get selectedConfiguration ( ) : { launch : ILaunch | undefined , name : string | undefined } {
441+ get selectedConfiguration ( ) : { launch : ILaunch | undefined , name : string | undefined , config : IConfig | undefined } {
438442 return {
439443 launch : this . selectedLaunch ,
440- name : this . selectedName
444+ name : this . selectedName ,
445+ config : this . selectedConfig
441446 } ;
442447 }
443448
@@ -453,7 +458,7 @@ export class ConfigurationManager implements IConfigurationManager {
453458 return undefined ;
454459 }
455460
456- selectConfiguration ( launch : ILaunch | undefined , name ?: string ) : void {
461+ selectConfiguration ( launch : ILaunch | undefined , name ?: string , config ?: IConfig ) : void {
457462 if ( typeof launch === 'undefined' ) {
458463 const rootUri = this . historyService . getLastActiveWorkspaceRoot ( ) ;
459464 launch = this . getLaunch ( rootUri ) ;
@@ -472,18 +477,19 @@ export class ConfigurationManager implements IConfigurationManager {
472477 this . storageService . remove ( DEBUG_SELECTED_ROOT , StorageScope . WORKSPACE ) ;
473478 }
474479 const names = launch ? launch . getConfigurationNames ( ) : [ ] ;
475- if ( name && names . indexOf ( name ) >= 0 ) {
480+ if ( ( name && names . indexOf ( name ) >= 0 ) || config ) {
476481 this . setSelectedLaunchName ( name ) ;
477- }
478- if ( ! this . selectedName || names . indexOf ( this . selectedName ) === - 1 ) {
482+ } else if ( ! this . selectedName || names . indexOf ( this . selectedName ) === - 1 ) {
479483 this . setSelectedLaunchName ( names . length ? names [ 0 ] : undefined ) ;
480484 }
481485
482- const configuration = this . selectedLaunch && this . selectedName ? this . selectedLaunch . getConfiguration ( this . selectedName ) : undefined ;
483- if ( configuration ) {
484- this . debugConfigurationTypeContext . set ( configuration . type ) ;
486+ this . selectedConfig = config || ( this . selectedLaunch && this . selectedName ? this . selectedLaunch . getConfiguration ( this . selectedName ) : undefined ) ;
487+ if ( this . selectedConfig ) {
488+ this . debugConfigurationTypeContext . set ( this . selectedConfig . type ) ;
489+ this . storageService . store ( DEBUG_SELECTED_CONFIG , JSON . stringify ( this . selectedConfig ) , StorageScope . WORKSPACE ) ;
485490 } else {
486491 this . debugConfigurationTypeContext . reset ( ) ;
492+ this . storageService . remove ( DEBUG_SELECTED_CONFIG , StorageScope . WORKSPACE ) ;
487493 }
488494
489495 if ( this . selectedLaunch !== previousLaunch || this . selectedName !== previousName ) {
0 commit comments