@@ -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 ( ) ;
@@ -58,10 +61,11 @@ export class DebugSessionFeature extends LanguageClientConsumer
5861 languageClient . onNotification (
5962 StartDebuggerNotificationType ,
6063 ( ) =>
64+ // TODO: Use a named debug configuration.
6165 vscode . debug . startDebugging ( undefined , {
6266 request : "launch" ,
6367 type : "PowerShell" ,
64- name : "PowerShell Interactive Session" ,
68+ name : "PowerShell: Interactive Session" ,
6569 } ) ) ;
6670
6771 languageClient . onNotification (
@@ -110,6 +114,7 @@ export class DebugSessionFeature extends LanguageClientConsumer
110114 debugConfigPickItems ,
111115 { placeHolder : "Select a PowerShell debug configuration" } ) ;
112116
117+ // TODO: Make these available in a dictionary and share them.
113118 switch ( launchSelection . id ) {
114119 case DebugConfig . LaunchCurrentFile :
115120 return [
@@ -154,10 +159,9 @@ export class DebugSessionFeature extends LanguageClientConsumer
154159
155160 // DebugConfigurationProvider method
156161 public async resolveDebugConfiguration (
157- folder : WorkspaceFolder | undefined ,
162+ _folder : WorkspaceFolder | undefined ,
158163 config : DebugConfiguration ,
159- token ?: CancellationToken ) : Promise < DebugConfiguration > {
160-
164+ _token ?: CancellationToken ) : Promise < DebugConfiguration > {
161165 // Make sure there is a session running before attempting to debug/run a program
162166 // TODO: Perhaps this should just wait until it's running or aborted.
163167 if ( this . sessionManager . getSessionStatus ( ) !== SessionStatus . Running ) {
@@ -213,10 +217,11 @@ export class DebugSessionFeature extends LanguageClientConsumer
213217 }
214218 }
215219
220+ // TODO: Use a named debug configuration.
216221 if ( generateLaunchConfig ) {
217222 // No launch.json, create the default configuration for both unsaved (Untitled) and saved documents.
218223 config . type = "PowerShell" ;
219- config . name = "PowerShell Launch Current File" ;
224+ config . name = "PowerShell: Launch Current File" ;
220225 config . request = "launch" ;
221226 config . args = [ ] ;
222227
@@ -240,7 +245,6 @@ export class DebugSessionFeature extends LanguageClientConsumer
240245 }
241246
242247 if ( config . request === "launch" ) {
243-
244248 // For debug launch of "current script" (saved or unsaved), warn before starting the debugger if either
245249 // A) there is not an active document
246250 // B) the unsaved document's language type is not PowerShell
@@ -355,7 +359,7 @@ export class SpecifyScriptArgsFeature implements vscode.Disposable {
355359 this . command . dispose ( ) ;
356360 }
357361
358- private specifyScriptArguments ( ) : Thenable < string > {
362+ private async specifyScriptArguments ( ) : Promise < string > {
359363 const powerShellDbgScriptArgsKey = "powerShellDebugScriptArgs" ;
360364
361365 const options : vscode . InputBoxOptions = {
@@ -368,15 +372,13 @@ export class SpecifyScriptArgsFeature implements vscode.Disposable {
368372 options . value = prevArgs ;
369373 }
370374
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- } ) ;
375+ const text = await vscode . window . showInputBox ( options ) ;
376+ // When user cancel's the input box (by pressing Esc), the text value is undefined.
377+ // Let's not blow away the previous settting.
378+ if ( text !== undefined ) {
379+ this . context . workspaceState . update ( powerShellDbgScriptArgsKey , text ) ;
380+ }
381+ return text ;
380382 }
381383}
382384
@@ -402,7 +404,7 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
402404
403405 private command : vscode . Disposable ;
404406 private waitingForClientToken : vscode . CancellationTokenSource ;
405- private getLanguageClientResolve : ( value ?: LanguageClient | Thenable < LanguageClient > ) => void ;
407+ private getLanguageClientResolve : ( value ?: LanguageClient | Promise < LanguageClient > ) => void ;
406408
407409 constructor ( ) {
408410 super ( ) ;
@@ -427,7 +429,7 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
427429 this . command . dispose ( ) ;
428430 }
429431
430- private getLanguageClient ( ) : Thenable < LanguageClient > {
432+ private getLanguageClient ( ) : Promise < LanguageClient > {
431433 if ( this . languageClient ) {
432434 return Promise . resolve ( this . languageClient ) ;
433435 } else {
@@ -466,46 +468,38 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
466468 }
467469 }
468470
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- } ) ;
471+ private async pickPSHostProcess ( ) : Promise < string > {
472+ const hostProcesses = await this . languageClient . sendRequest ( GetPSHostProcessesRequestType , { } ) ;
473+ // Start with the current PowerShell process in the list.
474+ const items : IProcessItem [ ] = [ {
475+ label : "Current" ,
476+ description : "The current PowerShell Integrated Console process." ,
477+ pid : "current" ,
478+ } ] ;
479+ for ( const p in hostProcesses ) {
480+ if ( hostProcesses . hasOwnProperty ( p ) ) {
481+ let windowTitle = "" ;
482+ if ( hostProcesses [ p ] . mainWindowTitle ) {
483+ windowTitle = `, Title: ${ hostProcesses [ p ] . mainWindowTitle } ` ;
490484 }
491- }
492485
493- if ( items . length === 0 ) {
494- return Promise . reject ( "There are no PowerShell host processes to attach to." ) ;
486+ items . push ( {
487+ label : hostProcesses [ p ] . processName ,
488+ description : `PID: ${ hostProcesses [ p ] . processId . toString ( ) } ${ windowTitle } ` ,
489+ pid : hostProcesses [ p ] . processId ,
490+ } ) ;
495491 }
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- } ) ;
492+ }
493+ if ( items . length === 0 ) {
494+ return Promise . reject ( "There are no PowerShell host processes to attach to." ) ;
495+ }
496+ const options : vscode . QuickPickOptions = {
497+ placeHolder : "Select a PowerShell host process to attach to" ,
498+ matchOnDescription : true ,
499+ matchOnDetail : true ,
500+ } ;
501+ const item = await vscode . window . showQuickPick ( items , options ) ;
502+ return item ? `${ item . pid } ` : undefined ;
509503 }
510504
511505 private clearWaitingToken ( ) {
@@ -533,7 +527,7 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
533527
534528 private command : vscode . Disposable ;
535529 private waitingForClientToken : vscode . CancellationTokenSource ;
536- private getLanguageClientResolve : ( value ?: LanguageClient | Thenable < LanguageClient > ) => void ;
530+ private getLanguageClientResolve : ( value ?: LanguageClient | Promise < LanguageClient > ) => void ;
537531
538532 constructor ( ) {
539533 super ( ) ;
@@ -557,7 +551,7 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
557551 this . command . dispose ( ) ;
558552 }
559553
560- private getLanguageClient ( ) : Thenable < LanguageClient > {
554+ private getLanguageClient ( ) : Promise < LanguageClient > {
561555 if ( this . languageClient ) {
562556 return Promise . resolve ( this . languageClient ) ;
563557 } else {
@@ -596,36 +590,29 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
596590 }
597591 }
598592
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- } ) ;
593+ private async pickRunspace ( processId : string ) : Promise < string > {
594+ const response = await this . languageClient . sendRequest ( GetRunspaceRequestType , { processId } ) ;
595+ const items : IRunspaceItem [ ] = [ ] ;
596+ for ( const runspace of response ) {
597+ // Skip default runspace
598+ if ( ( runspace . id === 1 || runspace . name === "PSAttachRunspace" )
599+ && processId === "current" ) {
600+ continue ;
615601 }
616602
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 ;
603+ items . push ( {
604+ label : runspace . name ,
605+ description : `ID: ${ runspace . id } - ${ runspace . availability } ` ,
606+ id : runspace . id . toString ( ) ,
627607 } ) ;
628- } ) ;
608+ }
609+ const options : vscode . QuickPickOptions = {
610+ placeHolder : "Select PowerShell runspace to debug" ,
611+ matchOnDescription : true ,
612+ matchOnDetail : true ,
613+ } ;
614+ const item = await vscode . window . showQuickPick ( items , options ) ;
615+ return item ? `${ item . id } ` : undefined ;
629616 }
630617
631618 private clearWaitingToken ( ) {
0 commit comments