@@ -35,7 +35,10 @@ export class DebugSessionFeature extends LanguageClientConsumer
35
35
context . subscriptions . push ( vscode . debug . registerDebugAdapterDescriptorFactory ( "PowerShell" , this ) )
36
36
}
37
37
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
+
39
42
const sessionDetails = session . configuration . createTemporaryIntegratedConsole
40
43
? this . tempSessionDetails
41
44
: this . sessionManager . getSessionDetails ( ) ;
@@ -58,10 +61,11 @@ export class DebugSessionFeature extends LanguageClientConsumer
58
61
languageClient . onNotification (
59
62
StartDebuggerNotificationType ,
60
63
( ) =>
64
+ // TODO: Use a named debug configuration.
61
65
vscode . debug . startDebugging ( undefined , {
62
66
request : "launch" ,
63
67
type : "PowerShell" ,
64
- name : "PowerShell Interactive Session" ,
68
+ name : "PowerShell: Interactive Session" ,
65
69
} ) ) ;
66
70
67
71
languageClient . onNotification (
@@ -110,6 +114,7 @@ export class DebugSessionFeature extends LanguageClientConsumer
110
114
debugConfigPickItems ,
111
115
{ placeHolder : "Select a PowerShell debug configuration" } ) ;
112
116
117
+ // TODO: Make these available in a dictionary and share them.
113
118
switch ( launchSelection . id ) {
114
119
case DebugConfig . LaunchCurrentFile :
115
120
return [
@@ -154,10 +159,9 @@ export class DebugSessionFeature extends LanguageClientConsumer
154
159
155
160
// DebugConfigurationProvider method
156
161
public async resolveDebugConfiguration (
157
- folder : WorkspaceFolder | undefined ,
162
+ _folder : WorkspaceFolder | undefined ,
158
163
config : DebugConfiguration ,
159
- token ?: CancellationToken ) : Promise < DebugConfiguration > {
160
-
164
+ _token ?: CancellationToken ) : Promise < DebugConfiguration > {
161
165
// Make sure there is a session running before attempting to debug/run a program
162
166
// TODO: Perhaps this should just wait until it's running or aborted.
163
167
if ( this . sessionManager . getSessionStatus ( ) !== SessionStatus . Running ) {
@@ -213,10 +217,11 @@ export class DebugSessionFeature extends LanguageClientConsumer
213
217
}
214
218
}
215
219
220
+ // TODO: Use a named debug configuration.
216
221
if ( generateLaunchConfig ) {
217
222
// No launch.json, create the default configuration for both unsaved (Untitled) and saved documents.
218
223
config . type = "PowerShell" ;
219
- config . name = "PowerShell Launch Current File" ;
224
+ config . name = "PowerShell: Launch Current File" ;
220
225
config . request = "launch" ;
221
226
config . args = [ ] ;
222
227
@@ -240,7 +245,6 @@ export class DebugSessionFeature extends LanguageClientConsumer
240
245
}
241
246
242
247
if ( config . request === "launch" ) {
243
-
244
248
// For debug launch of "current script" (saved or unsaved), warn before starting the debugger if either
245
249
// A) there is not an active document
246
250
// B) the unsaved document's language type is not PowerShell
@@ -355,7 +359,7 @@ export class SpecifyScriptArgsFeature implements vscode.Disposable {
355
359
this . command . dispose ( ) ;
356
360
}
357
361
358
- private specifyScriptArguments ( ) : Thenable < string > {
362
+ private async specifyScriptArguments ( ) : Promise < string > {
359
363
const powerShellDbgScriptArgsKey = "powerShellDebugScriptArgs" ;
360
364
361
365
const options : vscode . InputBoxOptions = {
@@ -368,15 +372,13 @@ export class SpecifyScriptArgsFeature implements vscode.Disposable {
368
372
options . value = prevArgs ;
369
373
}
370
374
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 ;
380
382
}
381
383
}
382
384
@@ -402,7 +404,7 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
402
404
403
405
private command : vscode . Disposable ;
404
406
private waitingForClientToken : vscode . CancellationTokenSource ;
405
- private getLanguageClientResolve : ( value ?: LanguageClient | Thenable < LanguageClient > ) => void ;
407
+ private getLanguageClientResolve : ( value ?: LanguageClient | Promise < LanguageClient > ) => void ;
406
408
407
409
constructor ( ) {
408
410
super ( ) ;
@@ -427,7 +429,7 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
427
429
this . command . dispose ( ) ;
428
430
}
429
431
430
- private getLanguageClient ( ) : Thenable < LanguageClient > {
432
+ private getLanguageClient ( ) : Promise < LanguageClient > {
431
433
if ( this . languageClient ) {
432
434
return Promise . resolve ( this . languageClient ) ;
433
435
} else {
@@ -466,46 +468,38 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
466
468
}
467
469
}
468
470
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 } ` ;
490
484
}
491
- }
492
485
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
+ } ) ;
495
491
}
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 ;
509
503
}
510
504
511
505
private clearWaitingToken ( ) {
@@ -533,7 +527,7 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
533
527
534
528
private command : vscode . Disposable ;
535
529
private waitingForClientToken : vscode . CancellationTokenSource ;
536
- private getLanguageClientResolve : ( value ?: LanguageClient | Thenable < LanguageClient > ) => void ;
530
+ private getLanguageClientResolve : ( value ?: LanguageClient | Promise < LanguageClient > ) => void ;
537
531
538
532
constructor ( ) {
539
533
super ( ) ;
@@ -557,7 +551,7 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
557
551
this . command . dispose ( ) ;
558
552
}
559
553
560
- private getLanguageClient ( ) : Thenable < LanguageClient > {
554
+ private getLanguageClient ( ) : Promise < LanguageClient > {
561
555
if ( this . languageClient ) {
562
556
return Promise . resolve ( this . languageClient ) ;
563
557
} else {
@@ -596,36 +590,29 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
596
590
}
597
591
}
598
592
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 ;
615
601
}
616
602
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 ( ) ,
627
607
} ) ;
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 ;
629
616
}
630
617
631
618
private clearWaitingToken ( ) {
0 commit comments