@@ -571,6 +571,68 @@ export class RubyLsp {
571
571
} ) ,
572
572
vscode . commands . registerCommand ( Command . NewMinitestFile , newMinitestFile ) ,
573
573
) ;
574
+ vscode . commands . registerCommand (
575
+ Command . MigrateLaunchConfiguration ,
576
+ async ( ) => {
577
+ const workspace = await this . showWorkspacePick ( ) ;
578
+
579
+ if ( ! workspace ) {
580
+ return ;
581
+ }
582
+
583
+ const launchConfig =
584
+ ( vscode . workspace
585
+ . getConfiguration ( "launch" )
586
+ ?. get ( "configurations" ) as any [ ] ) || [ ] ;
587
+
588
+ const updatedLaunchConfig = launchConfig . map ( ( config : any ) => {
589
+ if ( config . type === "rdbg" ) {
590
+ if ( config . request === "launch" ) {
591
+ const newConfig = { ...config } ;
592
+ newConfig . type = "ruby_lsp" ;
593
+
594
+ if ( newConfig . askParameters !== true ) {
595
+ delete newConfig . rdbgPath ;
596
+ delete newConfig . cwd ;
597
+ delete newConfig . useBundler ;
598
+
599
+ const command = ( newConfig . command || "" ) . replace (
600
+ "${workspaceRoot}/" ,
601
+ "" ,
602
+ ) ;
603
+ const script = newConfig . script || "" ;
604
+ const args = ( newConfig . args || [ ] ) . join ( " " ) ;
605
+ newConfig . program = `${ command } ${ script } ${ args } ` . trim ( ) ;
606
+
607
+ delete newConfig . command ;
608
+ delete newConfig . script ;
609
+ delete newConfig . args ;
610
+ delete newConfig . askParameters ;
611
+ }
612
+
613
+ return newConfig ;
614
+ } else if ( config . request === "attach" ) {
615
+ const newConfig = { ...config } ;
616
+ newConfig . type = "ruby_lsp" ;
617
+ // rdbg's `debugPort` could be socket path, or port number, or host:port
618
+ // we don't do complex parsing here, just assume it's socket path
619
+ newConfig . debugSocketPath = config . debugPort ;
620
+
621
+ return newConfig ;
622
+ }
623
+ }
624
+ return config ;
625
+ } ) ;
626
+
627
+ await vscode . workspace
628
+ . getConfiguration ( "launch" )
629
+ . update (
630
+ "configurations" ,
631
+ updatedLaunchConfig ,
632
+ vscode . ConfigurationTarget . Workspace ,
633
+ ) ;
634
+ } ,
635
+ ) ;
574
636
}
575
637
576
638
// Get the current active workspace based on which file is opened in the editor
0 commit comments