@@ -49,7 +49,7 @@ class RobotCodeDebugConfigurationProvider implements vscode.DebugConfigurationPr
4949
5050 // eslint-disable-next-line class-methods-use-this
5151 async _resolveDebugConfiguration (
52- _folder : vscode . WorkspaceFolder | undefined ,
52+ folder : vscode . WorkspaceFolder | undefined ,
5353 debugConfiguration : vscode . DebugConfiguration ,
5454 token ?: vscode . CancellationToken
5555 ) : Promise < vscode . DebugConfiguration > {
@@ -71,23 +71,23 @@ class RobotCodeDebugConfigurationProvider implements vscode.DebugConfigurationPr
7171 }
7272 }
7373
74- return debugConfiguration ;
75- }
74+ const config = vscode . workspace . getConfiguration ( CONFIG_SECTION , folder ) ;
7675
77- resolveDebugConfigurationWithSubstitutedVariables (
78- folder : vscode . WorkspaceFolder | undefined ,
79- debugConfiguration : vscode . DebugConfiguration ,
80- _token ?: vscode . CancellationToken
81- ) : vscode . ProviderResult < vscode . DebugConfiguration > {
82- return this . _resolveDebugConfigurationWithSubstitutedVariablesAsync ( folder , debugConfiguration , _token ) ;
83- }
76+ const template = config . get ( "debug.defaultConfiguration" , { } ) ;
8477
85- async _resolveDebugConfigurationWithSubstitutedVariablesAsync (
86- folder : vscode . WorkspaceFolder | undefined ,
87- debugConfiguration : vscode . DebugConfiguration ,
88- _token ?: vscode . CancellationToken
89- ) : Promise < vscode . DebugConfiguration > {
90- const config = vscode . workspace . getConfiguration ( CONFIG_SECTION , folder ) ;
78+ const defaultLaunchConfig =
79+ vscode . workspace
80+ . getConfiguration ( "launch" , folder )
81+ ?. get < { [ Key : string ] : unknown } [ ] > ( "configurations" )
82+ ?. find (
83+ ( v ) =>
84+ v ?. type === "robotcode" &&
85+ ( v ?. purpose === "default" || ( Array . isArray ( v ?. purpose ) && v ?. purpose ?. indexOf ( "default" ) > - 1 ) )
86+ ) ?? { } ;
87+
88+ console . log ( defaultLaunchConfig ) ;
89+
90+ debugConfiguration = { ...template , ...defaultLaunchConfig , ...debugConfiguration } ;
9191
9292 try {
9393 if ( path . isAbsolute ( debugConfiguration . target ) ) {
@@ -101,23 +101,27 @@ class RobotCodeDebugConfigurationProvider implements vscode.DebugConfigurationPr
101101
102102 debugConfiguration . robotPythonPath = [
103103 ...config . get < string [ ] > ( "robot.pythonPath" , [ ] ) ,
104+ ...( Array . isArray ( defaultLaunchConfig ?. robotPythonPath ) ? defaultLaunchConfig . robotPythonPath : [ ] ) ,
104105 ...( debugConfiguration . robotPythonPath ?? [ ] ) ,
105106 ] ;
106107
107108 debugConfiguration . args = [ ...config . get < string [ ] > ( "robot.args" , [ ] ) , ...( debugConfiguration . args ?? [ ] ) ] ;
108109
109110 debugConfiguration . variableFiles = [
110111 ...config . get < string [ ] > ( "robot.variableFiles" , [ ] ) ,
112+ ...( Array . isArray ( defaultLaunchConfig ?. variableFiles ) ? defaultLaunchConfig . variableFiles : [ ] ) ,
111113 ...( debugConfiguration . variableFiles ?? [ ] ) ,
112114 ] ;
113115
114116 debugConfiguration . variables = {
115117 ...config . get < { [ Key : string ] : unknown } > ( "robot.variables" , { } ) ,
118+ ...( Array . isArray ( defaultLaunchConfig ?. variables ) ? defaultLaunchConfig . variables : [ ] ) ,
116119 ...( debugConfiguration . variables ?? { } ) ,
117120 } ;
118121
119122 debugConfiguration . env = {
120123 ...config . get < { [ Key : string ] : unknown } > ( "robot.env" , { } ) ,
124+ ...( defaultLaunchConfig ?. env ?? { } ) ,
121125 ...( debugConfiguration . env ?? { } ) ,
122126 } ;
123127
@@ -157,9 +161,7 @@ class RobotCodeDebugConfigurationProvider implements vscode.DebugConfigurationPr
157161 }
158162 }
159163
160- const template = config . get ( "debug.defaultConfiguration" , { } ) ;
161-
162- return { ...template , ...debugConfiguration } ;
164+ return debugConfiguration ;
163165 }
164166}
165167
@@ -344,13 +346,23 @@ export class DebugManager {
344346
345347 args . push ( `robotcode.debugger.modifiers.ExcludedByLongName${ separator } ${ excluded . join ( separator ) } ` ) ;
346348 }
347- const template = config . get ( "debug.defaultConfiguration" , { } ) ;
349+
350+ const testLaunchConfig =
351+ vscode . workspace
352+ . getConfiguration ( "launch" , folder )
353+ ?. get < { [ Key : string ] : unknown } [ ] > ( "configurations" )
354+ ?. find (
355+ ( v ) =>
356+ v ?. type === "robotcode" &&
357+ ( v ?. purpose === "test" || ( Array . isArray ( v ?. purpose ) && v ?. purpose ?. indexOf ( "test" ) > - 1 ) )
358+ ) ?? { } ;
359+
348360 const paths = config . get ( "robot.paths" , [ ] ) ;
349361
350362 await vscode . debug . startDebugging (
351363 folder ,
352364 {
353- ...template ,
365+ ...testLaunchConfig ,
354366 ...{
355367 type : "robotcode" ,
356368 name : "RobotCode: Run Tests" ,
@@ -379,26 +391,34 @@ export class DebugManager {
379391 options &&
380392 options . port
381393 ) {
382- await vscode . debug . startDebugging (
383- session . workspaceFolder ,
384- {
385- ...session . configuration . pythonConfiguration ,
386- ...{
387- type : "python" ,
388- name : `Python ${ session . name } ` ,
389- request : "attach" ,
390- connect : {
391- port : options . port ,
392- } ,
394+ let pythonConfiguration = session . configuration . pythonConfiguration ?? { } ;
395+
396+ if ( typeof pythonConfiguration === "string" || pythonConfiguration instanceof String ) {
397+ pythonConfiguration =
398+ vscode . workspace
399+ . getConfiguration ( "launch" , session . workspaceFolder )
400+ ?. get < { [ Key : string ] : unknown } [ ] > ( "configurations" )
401+ ?. find ( ( v ) => v ?. type === "python" && v ?. name === pythonConfiguration ) ?? { } ;
402+ }
403+
404+ const debugConfiguration = {
405+ ...pythonConfiguration ,
406+ ...{
407+ type : "python" ,
408+ name : `Python ${ session . name } ` ,
409+ request : "attach" ,
410+ connect : {
411+ port : options . port ,
393412 } ,
394413 } ,
395- {
396- parentSession : session ,
397- compact : true ,
398- lifecycleManagedByParent : false ,
399- consoleMode : vscode . DebugConsoleMode . MergeWithParent ,
400- }
401- ) ;
414+ } ;
415+
416+ await vscode . debug . startDebugging ( session . workspaceFolder , debugConfiguration , {
417+ parentSession : session ,
418+ compact : true ,
419+ lifecycleManagedByParent : false ,
420+ consoleMode : vscode . DebugConsoleMode . MergeWithParent ,
421+ } ) ;
402422 }
403423 }
404424
0 commit comments