@@ -32,7 +32,7 @@ import { launchSchema, debuggersExtPoint, breakpointsExtPoint } from 'vs/workben
3232import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput' ;
3333import { IContextKeyService , IContextKey } from 'vs/platform/contextkey/common/contextkey' ;
3434import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles' ;
35- import { CancellationToken } from 'vs/base/common/cancellation' ;
35+ import { CancellationToken , CancellationTokenSource } from 'vs/base/common/cancellation' ;
3636import { withUndefinedAsNull } from 'vs/base/common/types' ;
3737import { sequence } from 'vs/base/common/async' ;
3838import { IHistoryService } from 'vs/workbench/services/history/common/history' ;
@@ -163,8 +163,8 @@ export class ConfigurationManager implements IConfigurationManager {
163163 return Promise . resolve ( undefined ) ;
164164 }
165165
166- getDebuggerLabel ( session : IDebugSession ) : string | undefined {
167- const dbgr = this . getDebugger ( session . configuration . type ) ;
166+ getDebuggerLabel ( type : string ) : string | undefined {
167+ const dbgr = this . getDebugger ( type ) ;
168168 if ( dbgr ) {
169169 return dbgr . label ;
170170 }
@@ -246,11 +246,36 @@ export class ConfigurationManager implements IConfigurationManager {
246246 return results . reduce ( ( first , second ) => first . concat ( second ) , [ ] ) ;
247247 }
248248
249- async provideDynamicDebugConfigurations ( folderUri : uri | undefined , type : string , token : CancellationToken ) : Promise < any [ ] > {
249+ async getDynamicProviders ( ) : Promise < { label : string , pick : ( ) => Promise < { launch : ILaunch , config : IConfig } | undefined > } [ ] > {
250250 await this . activateDebuggers ( 'onDebugDynamicConfigurations' ) ;
251- const results = await Promise . all ( this . configProviders . filter ( p => p . type === type && p . scope === DebugConfigurationProviderScope . Dynamic && p . provideDebugConfigurations ) . map ( p => p . provideDebugConfigurations ! ( folderUri , token ) ) ) ;
251+ const dynamicProviders = this . configProviders . filter ( p => p . scope === DebugConfigurationProviderScope . Dynamic && p . provideDebugConfigurations ) ;
252+ return dynamicProviders . map ( provider => {
253+ return {
254+ label : this . getDebuggerLabel ( provider . type ) ! ,
255+ pick : async ( ) => {
256+ const token = new CancellationTokenSource ( ) ;
257+ const picks : Promise < { label : string , launch : ILaunch , config : IConfig } [ ] > [ ] = [ ] ;
258+ this . getLaunches ( ) . forEach ( launch => {
259+ if ( launch . workspace ) {
260+ picks . push ( provider . provideDebugConfigurations ! ( launch . workspace . uri , token . token ) . then ( configurations => configurations . map ( config => ( {
261+ label : config . name ,
262+ config,
263+ launch
264+ } ) ) ) ) ;
265+ }
266+ } ) ;
267+ const promiseOfPicks = Promise . all ( picks ) . then ( result => result . reduce ( ( first , second ) => first . concat ( second ) , [ ] ) ) ;
252268
253- return results . reduce ( ( first , second ) => first . concat ( second ) , [ ] ) ;
269+ const result = await this . quickInputService . pick < { label : string , launch : ILaunch , config : IConfig } > ( promiseOfPicks , { placeHolder : nls . localize ( 'selectConfiguration' , "Select Debug Configuration" ) } ) ;
270+ if ( ! result ) {
271+ // User canceled quick input we should notify the provider to cancel computing configurations
272+ token . cancel ( ) ;
273+ }
274+
275+ return result ;
276+ }
277+ } ;
278+ } ) ;
254279 }
255280
256281 getAllConfigurations ( ) : { launch : ILaunch ; name : string ; presentation ?: IConfigPresentation } [ ] {
0 commit comments