@@ -464,22 +464,35 @@ await requestContext.SendError(
464
464
// InitializedEvent will be sent as soon as the RunspaceChanged
465
465
// event gets fired with the attached runspace.
466
466
467
- var runspaceId = 1 ;
468
- if ( ! int . TryParse ( attachParams . RunspaceId , out runspaceId ) || runspaceId <= 0 )
467
+ string debugRunspaceCmd ;
468
+ if ( attachParams . RunspaceName != null )
469
469
{
470
- Logger . Write (
471
- LogLevel . Error ,
472
- $ "Attach request failed, '{ attachParams . RunspaceId } ' is an invalid value for the processId.") ;
470
+ debugRunspaceCmd = $ "\n Debug-Runspace -Name '{ attachParams . RunspaceName } '";
471
+ }
472
+ else if ( attachParams . RunspaceId != null )
473
+ {
474
+ if ( ! int . TryParse ( attachParams . RunspaceId , out int runspaceId ) || runspaceId <= 0 )
475
+ {
476
+ Logger . Write (
477
+ LogLevel . Error ,
478
+ $ "Attach request failed, '{ attachParams . RunspaceId } ' is an invalid value for the processId.") ;
473
479
474
- await requestContext . SendError (
475
- "A positive integer must be specified for the RunspaceId field." ) ;
480
+ await requestContext . SendError (
481
+ "A positive integer must be specified for the RunspaceId field." ) ;
476
482
477
- return ;
483
+ return ;
484
+ }
485
+
486
+ debugRunspaceCmd = $ "\n Debug-Runspace -Id { runspaceId } ";
487
+ }
488
+ else
489
+ {
490
+ debugRunspaceCmd = "\n Debug-Runspace -Id 1" ;
478
491
}
479
492
480
493
_waitingForAttach = true ;
481
494
Task nonAwaitedTask = _editorSession . PowerShellContext
482
- . ExecuteScriptString ( $ " \n Debug-Runspace -Id { runspaceId } " )
495
+ . ExecuteScriptString ( debugRunspaceCmd )
483
496
. ContinueWith ( OnExecutionCompleted ) ;
484
497
485
498
await requestContext . SendResult ( null ) ;
0 commit comments