@@ -35,7 +35,10 @@ export class DebugSessionFeature extends LanguageClientConsumer
3535 context . subscriptions . push ( vscode . debug . registerDebugAdapterDescriptorFactory ( "PowerShell" , this ) )
3636 }
3737
38- createDebugAdapterDescriptor ( session : vscode . DebugSession , executable : vscode . DebugAdapterExecutable ) : vscode . ProviderResult < vscode . DebugAdapterDescriptor > {
38+ createDebugAdapterDescriptor (
39+ session : vscode . DebugSession ,
40+ _executable : vscode . DebugAdapterExecutable ) : vscode . ProviderResult < vscode . DebugAdapterDescriptor > {
41+
3942 const sessionDetails = session . configuration . createTemporaryIntegratedConsole
4043 ? this . tempSessionDetails
4144 : this . sessionManager . getSessionDetails ( ) ;
@@ -154,10 +157,9 @@ export class DebugSessionFeature extends LanguageClientConsumer
154157
155158 // DebugConfigurationProvider method
156159 public async resolveDebugConfiguration (
157- folder : WorkspaceFolder | undefined ,
160+ _folder : WorkspaceFolder | undefined ,
158161 config : DebugConfiguration ,
159- token ?: CancellationToken ) : Promise < DebugConfiguration > {
160-
162+ _token ?: CancellationToken ) : Promise < DebugConfiguration > {
161163 // Make sure there is a session running before attempting to debug/run a program
162164 // TODO: Perhaps this should just wait until it's running or aborted.
163165 if ( this . sessionManager . getSessionStatus ( ) !== SessionStatus . Running ) {
@@ -216,7 +218,7 @@ export class DebugSessionFeature extends LanguageClientConsumer
216218 if ( generateLaunchConfig ) {
217219 // No launch.json, create the default configuration for both unsaved (Untitled) and saved documents.
218220 config . type = "PowerShell" ;
219- config . name = "PowerShell Launch Current File" ;
221+ config . name = "PowerShell: Launch Current File" ;
220222 config . request = "launch" ;
221223 config . args = [ ] ;
222224
@@ -240,7 +242,6 @@ export class DebugSessionFeature extends LanguageClientConsumer
240242 }
241243
242244 if ( config . request === "launch" ) {
243-
244245 // For debug launch of "current script" (saved or unsaved), warn before starting the debugger if either
245246 // A) there is not an active document
246247 // B) the unsaved document's language type is not PowerShell
@@ -355,7 +356,7 @@ export class SpecifyScriptArgsFeature implements vscode.Disposable {
355356 this . command . dispose ( ) ;
356357 }
357358
358- private specifyScriptArguments ( ) : Thenable < string > {
359+ private async specifyScriptArguments ( ) : Promise < string > {
359360 const powerShellDbgScriptArgsKey = "powerShellDebugScriptArgs" ;
360361
361362 const options : vscode . InputBoxOptions = {
@@ -368,15 +369,13 @@ export class SpecifyScriptArgsFeature implements vscode.Disposable {
368369 options . value = prevArgs ;
369370 }
370371
371- return vscode . window . showInputBox ( options ) . then ( ( text ) => {
372- // When user cancel's the input box (by pressing Esc), the text value is undefined.
373- // Let's not blow away the previous settting.
374- if ( text !== undefined ) {
375- this . context . workspaceState . update ( powerShellDbgScriptArgsKey , text ) ;
376- }
377-
378- return text ;
379- } ) ;
372+ const text = await vscode . window . showInputBox ( options ) ;
373+ // When user cancel's the input box (by pressing Esc), the text value is undefined.
374+ // Let's not blow away the previous settting.
375+ if ( text !== undefined ) {
376+ this . context . workspaceState . update ( powerShellDbgScriptArgsKey , text ) ;
377+ }
378+ return text ;
380379 }
381380}
382381
@@ -402,7 +401,7 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
402401
403402 private command : vscode . Disposable ;
404403 private waitingForClientToken : vscode . CancellationTokenSource ;
405- private getLanguageClientResolve : ( value ?: LanguageClient | Thenable < LanguageClient > ) => void ;
404+ private getLanguageClientResolve : ( value ?: LanguageClient | Promise < LanguageClient > ) => void ;
406405
407406 constructor ( ) {
408407 super ( ) ;
@@ -427,7 +426,7 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
427426 this . command . dispose ( ) ;
428427 }
429428
430- private getLanguageClient ( ) : Thenable < LanguageClient > {
429+ private getLanguageClient ( ) : Promise < LanguageClient > {
431430 if ( this . languageClient ) {
432431 return Promise . resolve ( this . languageClient ) ;
433432 } else {
@@ -466,46 +465,38 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
466465 }
467466 }
468467
469- private pickPSHostProcess ( ) : Thenable < string > {
470- return this . languageClient . sendRequest ( GetPSHostProcessesRequestType , { } ) . then ( ( hostProcesses ) => {
471- // Start with the current PowerShell process in the list.
472- const items : IProcessItem [ ] = [ {
473- label : "Current" ,
474- description : "The current PowerShell Integrated Console process." ,
475- pid : "current" ,
476- } ] ;
477-
478- for ( const p in hostProcesses ) {
479- if ( hostProcesses . hasOwnProperty ( p ) ) {
480- let windowTitle = "" ;
481- if ( hostProcesses [ p ] . mainWindowTitle ) {
482- windowTitle = `, Title: ${ hostProcesses [ p ] . mainWindowTitle } ` ;
483- }
484-
485- items . push ( {
486- label : hostProcesses [ p ] . processName ,
487- description : `PID: ${ hostProcesses [ p ] . processId . toString ( ) } ${ windowTitle } ` ,
488- pid : hostProcesses [ p ] . processId ,
489- } ) ;
468+ private async pickPSHostProcess ( ) : Promise < string > {
469+ const hostProcesses = await this . languageClient . sendRequest ( GetPSHostProcessesRequestType , { } ) ;
470+ // Start with the current PowerShell process in the list.
471+ const items : IProcessItem [ ] = [ {
472+ label : "Current" ,
473+ description : "The current PowerShell Integrated Console process." ,
474+ pid : "current" ,
475+ } ] ;
476+ for ( const p in hostProcesses ) {
477+ if ( hostProcesses . hasOwnProperty ( p ) ) {
478+ let windowTitle = "" ;
479+ if ( hostProcesses [ p ] . mainWindowTitle ) {
480+ windowTitle = `, Title: ${ hostProcesses [ p ] . mainWindowTitle } ` ;
490481 }
491- }
492482
493- if ( items . length === 0 ) {
494- return Promise . reject ( "There are no PowerShell host processes to attach to." ) ;
483+ items . push ( {
484+ label : hostProcesses [ p ] . processName ,
485+ description : `PID: ${ hostProcesses [ p ] . processId . toString ( ) } ${ windowTitle } ` ,
486+ pid : hostProcesses [ p ] . processId ,
487+ } ) ;
495488 }
496-
497- const options : vscode . QuickPickOptions = {
498- placeHolder : "Select a PowerShell host process to attach to" ,
499- matchOnDescription : true ,
500- matchOnDetail : true ,
501- } ;
502-
503- return vscode . window . showQuickPick ( items , options ) . then ( ( item ) => {
504- // Return undefined when user presses Esc.
505- // This prevents VSCode from opening launch.json in this case which happens if we return "".
506- return item ? `${ item . pid } ` : undefined ;
507- } ) ;
508- } ) ;
489+ }
490+ if ( items . length === 0 ) {
491+ return Promise . reject ( "There are no PowerShell host processes to attach to." ) ;
492+ }
493+ const options : vscode . QuickPickOptions = {
494+ placeHolder : "Select a PowerShell host process to attach to" ,
495+ matchOnDescription : true ,
496+ matchOnDetail : true ,
497+ } ;
498+ const item = await vscode . window . showQuickPick ( items , options ) ;
499+ return item ? `${ item . pid } ` : undefined ;
509500 }
510501
511502 private clearWaitingToken ( ) {
@@ -533,7 +524,7 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
533524
534525 private command : vscode . Disposable ;
535526 private waitingForClientToken : vscode . CancellationTokenSource ;
536- private getLanguageClientResolve : ( value ?: LanguageClient | Thenable < LanguageClient > ) => void ;
527+ private getLanguageClientResolve : ( value ?: LanguageClient | Promise < LanguageClient > ) => void ;
537528
538529 constructor ( ) {
539530 super ( ) ;
@@ -557,7 +548,7 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
557548 this . command . dispose ( ) ;
558549 }
559550
560- private getLanguageClient ( ) : Thenable < LanguageClient > {
551+ private getLanguageClient ( ) : Promise < LanguageClient > {
561552 if ( this . languageClient ) {
562553 return Promise . resolve ( this . languageClient ) ;
563554 } else {
@@ -596,36 +587,29 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
596587 }
597588 }
598589
599- private pickRunspace ( processId ) : Thenable < string > {
600- return this . languageClient . sendRequest ( GetRunspaceRequestType , { processId } ) . then ( ( response ) => {
601- const items : IRunspaceItem [ ] = [ ] ;
602-
603- for ( const runspace of response ) {
604- // Skip default runspace
605- if ( ( runspace . id === 1 || runspace . name === "PSAttachRunspace" )
606- && processId === "current" ) {
607- continue ;
608- }
609-
610- items . push ( {
611- label : runspace . name ,
612- description : `ID: ${ runspace . id } - ${ runspace . availability } ` ,
613- id : runspace . id . toString ( ) ,
614- } ) ;
590+ private async pickRunspace ( processId : string ) : Promise < string > {
591+ const response = await this . languageClient . sendRequest ( GetRunspaceRequestType , { processId } ) ;
592+ const items : IRunspaceItem [ ] = [ ] ;
593+ for ( const runspace of response ) {
594+ // Skip default runspace
595+ if ( ( runspace . id === 1 || runspace . name === "PSAttachRunspace" )
596+ && processId === "current" ) {
597+ continue ;
615598 }
616599
617- const options : vscode . QuickPickOptions = {
618- placeHolder : "Select PowerShell runspace to debug" ,
619- matchOnDescription : true ,
620- matchOnDetail : true ,
621- } ;
622-
623- return vscode . window . showQuickPick ( items , options ) . then ( ( item ) => {
624- // Return undefined when user presses Esc.
625- // This prevents VSCode from opening launch.json in this case which happens if we return "".
626- return item ? `${ item . id } ` : undefined ;
600+ items . push ( {
601+ label : runspace . name ,
602+ description : `ID: ${ runspace . id } - ${ runspace . availability } ` ,
603+ id : runspace . id . toString ( ) ,
627604 } ) ;
628- } ) ;
605+ }
606+ const options : vscode . QuickPickOptions = {
607+ placeHolder : "Select PowerShell runspace to debug" ,
608+ matchOnDescription : true ,
609+ matchOnDetail : true ,
610+ } ;
611+ const item = await vscode . window . showQuickPick ( items , options ) ;
612+ return item ? `${ item . id } ` : undefined ;
629613 }
630614
631615 private clearWaitingToken ( ) {
0 commit comments