@@ -46,6 +46,7 @@ jsonRegistry.registerSchema(launchSchemaId, launchSchema);
4646
4747const DEBUG_SELECTED_CONFIG_NAME_KEY = 'debug.selectedconfigname' ;
4848const DEBUG_SELECTED_ROOT = 'debug.selectedroot' ;
49+ const DEBUG_SELECTED_DYNAMIC_CONFIG = 'debug.selecteddynamicconfig' ;
4950
5051interface IDynamicPickItem { label : string , launch : ILaunch , config : IConfig }
5152
@@ -83,23 +84,30 @@ export class ConfigurationManager implements IConfigurationManager {
8384 this . toDispose = [ ] ;
8485 this . initLaunches ( ) ;
8586 this . registerListeners ( ) ;
86- const previousSelectedRoot = this . storageService . get ( DEBUG_SELECTED_ROOT , StorageScope . WORKSPACE ) ;
87- const previousSelectedLaunch = this . launches . find ( l => l . uri . toString ( ) === previousSelectedRoot ) ;
8887 this . debugConfigurationTypeContext = CONTEXT_DEBUG_CONFIGURATION_TYPE . bindTo ( contextKeyService ) ;
8988 this . debuggersAvailable = CONTEXT_DEBUGGERS_AVAILABLE . bindTo ( contextKeyService ) ;
90- if ( previousSelectedLaunch && previousSelectedLaunch . getConfigurationNames ( ) . length ) {
91- this . selectConfiguration ( previousSelectedLaunch , this . storageService . get ( DEBUG_SELECTED_CONFIG_NAME_KEY , StorageScope . WORKSPACE ) ) ;
92- } else if ( this . launches . length > 0 ) {
93- this . selectConfiguration ( undefined ) ;
94- }
89+
9590 }
9691
9792 // debuggers
9893
9994 registerDebugAdapterFactory ( debugTypes : string [ ] , debugAdapterLauncher : IDebugAdapterFactory ) : IDisposable {
95+ const firstRegistration = this . debugAdapterFactories . size === 0 ;
10096 debugTypes . forEach ( debugType => this . debugAdapterFactories . set ( debugType , debugAdapterLauncher ) ) ;
10197 this . debuggersAvailable . set ( this . debugAdapterFactories . size > 0 ) ;
10298 this . _onDidRegisterDebugger . fire ( ) ;
99+ if ( firstRegistration ) {
100+ const previousSelectedRoot = this . storageService . get ( DEBUG_SELECTED_ROOT , StorageScope . WORKSPACE ) ;
101+ const previousSelectedLaunch = this . launches . find ( l => l . uri . toString ( ) === previousSelectedRoot ) ;
102+ if ( previousSelectedLaunch && previousSelectedLaunch . getConfigurationNames ( ) . length ) {
103+ const name = this . storageService . get ( DEBUG_SELECTED_CONFIG_NAME_KEY , StorageScope . WORKSPACE ) ;
104+ const configStr = this . storageService . get ( DEBUG_SELECTED_DYNAMIC_CONFIG , StorageScope . WORKSPACE ) ;
105+ const config = configStr ? JSON . parse ( configStr ) : undefined ;
106+ this . selectConfiguration ( previousSelectedLaunch , name , config ) ;
107+ } else if ( this . launches . length > 0 ) {
108+ this . selectConfiguration ( undefined ) ;
109+ }
110+ }
103111
104112 return {
105113 dispose : ( ) => {
@@ -534,6 +542,12 @@ export class ConfigurationManager implements IConfigurationManager {
534542 }
535543
536544 this . selectedConfig = config ;
545+ if ( config ) {
546+ // Only dynamic configurations get passed in the selectConfiguration. We should store them #96293
547+ this . storageService . store ( DEBUG_SELECTED_DYNAMIC_CONFIG , JSON . stringify ( config ) , StorageScope . WORKSPACE ) ;
548+ } else {
549+ this . storageService . remove ( DEBUG_SELECTED_DYNAMIC_CONFIG , StorageScope . WORKSPACE ) ;
550+ }
537551 const configForType = this . selectedConfig || ( this . selectedLaunch && this . selectedName ? this . selectedLaunch . getConfiguration ( this . selectedName ) : undefined ) ;
538552 if ( configForType ) {
539553 this . debugConfigurationTypeContext . set ( configForType . type ) ;
0 commit comments