@@ -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 ( ) ;
@@ -154,10 +157,9 @@ export class DebugSessionFeature extends LanguageClientConsumer
154
157
155
158
// DebugConfigurationProvider method
156
159
public async resolveDebugConfiguration (
157
- folder : WorkspaceFolder | undefined ,
160
+ _folder : WorkspaceFolder | undefined ,
158
161
config : DebugConfiguration ,
159
- token ?: CancellationToken ) : Promise < DebugConfiguration > {
160
-
162
+ _token ?: CancellationToken ) : Promise < DebugConfiguration > {
161
163
// Make sure there is a session running before attempting to debug/run a program
162
164
// TODO: Perhaps this should just wait until it's running or aborted.
163
165
if ( this . sessionManager . getSessionStatus ( ) !== SessionStatus . Running ) {
@@ -216,7 +218,7 @@ export class DebugSessionFeature extends LanguageClientConsumer
216
218
if ( generateLaunchConfig ) {
217
219
// No launch.json, create the default configuration for both unsaved (Untitled) and saved documents.
218
220
config . type = "PowerShell" ;
219
- config . name = "PowerShell Launch Current File" ;
221
+ config . name = "PowerShell: Launch Current File" ;
220
222
config . request = "launch" ;
221
223
config . args = [ ] ;
222
224
@@ -240,7 +242,6 @@ export class DebugSessionFeature extends LanguageClientConsumer
240
242
}
241
243
242
244
if ( config . request === "launch" ) {
243
-
244
245
// For debug launch of "current script" (saved or unsaved), warn before starting the debugger if either
245
246
// A) there is not an active document
246
247
// B) the unsaved document's language type is not PowerShell
@@ -355,7 +356,7 @@ export class SpecifyScriptArgsFeature implements vscode.Disposable {
355
356
this . command . dispose ( ) ;
356
357
}
357
358
358
- private specifyScriptArguments ( ) : Thenable < string > {
359
+ private async specifyScriptArguments ( ) : Promise < string > {
359
360
const powerShellDbgScriptArgsKey = "powerShellDebugScriptArgs" ;
360
361
361
362
const options : vscode . InputBoxOptions = {
@@ -368,15 +369,13 @@ export class SpecifyScriptArgsFeature implements vscode.Disposable {
368
369
options . value = prevArgs ;
369
370
}
370
371
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 ;
380
379
}
381
380
}
382
381
@@ -402,7 +401,7 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
402
401
403
402
private command : vscode . Disposable ;
404
403
private waitingForClientToken : vscode . CancellationTokenSource ;
405
- private getLanguageClientResolve : ( value ?: LanguageClient | Thenable < LanguageClient > ) => void ;
404
+ private getLanguageClientResolve : ( value ?: LanguageClient | Promise < LanguageClient > ) => void ;
406
405
407
406
constructor ( ) {
408
407
super ( ) ;
@@ -427,7 +426,7 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
427
426
this . command . dispose ( ) ;
428
427
}
429
428
430
- private getLanguageClient ( ) : Thenable < LanguageClient > {
429
+ private getLanguageClient ( ) : Promise < LanguageClient > {
431
430
if ( this . languageClient ) {
432
431
return Promise . resolve ( this . languageClient ) ;
433
432
} else {
@@ -466,46 +465,38 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
466
465
}
467
466
}
468
467
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 } ` ;
490
481
}
491
- }
492
482
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
+ } ) ;
495
488
}
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 ;
509
500
}
510
501
511
502
private clearWaitingToken ( ) {
@@ -533,7 +524,7 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
533
524
534
525
private command : vscode . Disposable ;
535
526
private waitingForClientToken : vscode . CancellationTokenSource ;
536
- private getLanguageClientResolve : ( value ?: LanguageClient | Thenable < LanguageClient > ) => void ;
527
+ private getLanguageClientResolve : ( value ?: LanguageClient | Promise < LanguageClient > ) => void ;
537
528
538
529
constructor ( ) {
539
530
super ( ) ;
@@ -557,7 +548,7 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
557
548
this . command . dispose ( ) ;
558
549
}
559
550
560
- private getLanguageClient ( ) : Thenable < LanguageClient > {
551
+ private getLanguageClient ( ) : Promise < LanguageClient > {
561
552
if ( this . languageClient ) {
562
553
return Promise . resolve ( this . languageClient ) ;
563
554
} else {
@@ -596,36 +587,29 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
596
587
}
597
588
}
598
589
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 ;
615
598
}
616
599
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 ( ) ,
627
604
} ) ;
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 ;
629
613
}
630
614
631
615
private clearWaitingToken ( ) {
0 commit comments