@@ -10,7 +10,7 @@ import { logger } from './utils/logger';
1010 * Interface for debugging handler operations
1111 */
1212export interface IDebuggingHandler {
13- handleStartDebugging ( args : { fileFullPath : string ; workingDirectory : string ; testName ?: string } ) : Promise < string > ;
13+ handleStartDebugging ( args : { fileFullPath : string ; workingDirectory : string ; testName ?: string ; configurationName ?: string } ) : Promise < string > ;
1414 handleStopDebugging ( ) : Promise < string > ;
1515 handleStepOver ( ) : Promise < string > ;
1616 handleStepInto ( ) : Promise < string > ;
@@ -48,11 +48,12 @@ export class DebuggingHandler implements IDebuggingHandler {
4848 fileFullPath : string ;
4949 workingDirectory : string ;
5050 testName ?: string ;
51+ configurationName ?: string ;
5152 } ) : Promise < string > {
52- const { fileFullPath, workingDirectory, testName } = args ;
53+ const { fileFullPath, workingDirectory, testName, configurationName } = args ;
5354
5455 try {
55- let selectedConfigName = await this . configManager . promptForConfiguration ( workingDirectory ) ;
56+ let selectedConfigName = configurationName ?? await this . configManager . promptForConfiguration ( workingDirectory ) ;
5657
5758 // Get debug configuration from launch.json or create default
5859 const debugConfig = await this . configManager . getDebugConfig (
@@ -75,7 +76,7 @@ export class DebuggingHandler implements IDebuggingHandler {
7576 const configInfo = selectedConfigName ? ` using configuration '${ selectedConfigName } '` : ' with default configuration' ;
7677 const testInfo = testName ? ` (test: ${ testName } )` : '' ;
7778 const currentState = await this . executor . getCurrentDebugState ( this . numNextLines ) ;
78- return `Debug session started successfully for: ${ fileFullPath } ${ configInfo } ${ testInfo } . Current state: ${ this . formatDebugState ( currentState ) } ` ;
79+ return `Debug session started successfully for: ${ fileFullPath } ${ configInfo } ${ testInfo } . Current state: ${ currentState . toString ( ) } ` ;
7980 } else {
8081 throw new Error ( 'Failed to start debug session. Make sure the appropriate language extension is installed.' ) ;
8182 }
@@ -137,8 +138,7 @@ export class DebuggingHandler implements IDebuggingHandler {
137138 // Wait for debugger state to change
138139 const afterState = await this . waitForStateChange ( beforeState ) ;
139140
140- // Format the debug state as a string
141- return this . formatDebugState ( afterState ) ;
141+ return afterState . toString ( ) ;
142142 } catch ( error ) {
143143 throw new Error ( `Error executing step over: ${ error } ` ) ;
144144 }
@@ -161,8 +161,7 @@ export class DebuggingHandler implements IDebuggingHandler {
161161 // Wait for debugger state to change
162162 const afterState = await this . waitForStateChange ( beforeState ) ;
163163
164- // Format the debug state as a string
165- return this . formatDebugState ( afterState ) ;
164+ return afterState . toString ( ) ;
166165 } catch ( error ) {
167166 throw new Error ( `Error executing step into: ${ error } ` ) ;
168167 }
@@ -185,8 +184,7 @@ export class DebuggingHandler implements IDebuggingHandler {
185184 // Wait for debugger state to change
186185 const afterState = await this . waitForStateChange ( beforeState ) ;
187186
188- // Format the debug state as a string
189- return this . formatDebugState ( afterState ) ;
187+ return afterState . toString ( ) ;
190188 } catch ( error ) {
191189 throw new Error ( `Error executing step out: ${ error } ` ) ;
192190 }
@@ -209,10 +207,7 @@ export class DebuggingHandler implements IDebuggingHandler {
209207 // Wait for debugger state to change
210208 const afterState = await this . waitForStateChange ( beforeState ) ;
211209
212- let result = this . formatDebugState ( afterState ) ;
213-
214-
215- return result ;
210+ return afterState . toString ( ) ;
216211 } catch ( error ) {
217212 throw new Error ( `Error executing continue: ${ error } ` ) ;
218213 }
@@ -421,55 +416,6 @@ export class DebuggingHandler implements IDebuggingHandler {
421416 }
422417 }
423418
424- /**
425- * Format debug state as a JSON string for structured output
426- */
427- private formatDebugState ( state : DebugState ) : string {
428- const stateObject : {
429- sessionActive : boolean ;
430- stackTrace ?: string [ ] ;
431- breakpoints ?: string [ ] ;
432- fileFullPath ?: string | null ;
433- fileName ?: string | null ;
434- currentLine ?: number | null ;
435- currentLineContent ?: string | null ;
436- nextLines ?: string [ ] ;
437- frameId ?: number | null ;
438- threadId ?: number | null ;
439- frameName ?: string | null ;
440- } = {
441- sessionActive : state . sessionActive ,
442- } ;
443-
444- if ( state . sessionActive ) {
445- // Compact stack trace: "functionName:line" format
446- stateObject . stackTrace = state . stackTrace . map ( frame =>
447- `${ frame . name } :${ frame . line || '?' } `
448- ) ;
449-
450- // Compact breakpoints list: "fileName:line" format
451- const breakpoints = this . executor . getBreakpoints ( ) ;
452- stateObject . breakpoints = breakpoints
453- . filter ( ( bp ) : bp is vscode . SourceBreakpoint => bp instanceof vscode . SourceBreakpoint )
454- . map ( bp => {
455- const fileName = bp . location . uri . fsPath . split ( / [ / \\ ] / ) . pop ( ) || 'unknown' ;
456- const line = bp . location . range . start . line + 1 ;
457- return `${ fileName } :${ line } ` ;
458- } ) ;
459-
460- stateObject . fileFullPath = state . fileFullPath ;
461- stateObject . fileName = state . fileName ;
462- stateObject . currentLine = state . currentLine ;
463- stateObject . currentLineContent = state . currentLineContent ;
464- stateObject . nextLines = state . nextLines ;
465- stateObject . frameId = state . frameId ;
466- stateObject . threadId = state . threadId ;
467- stateObject . frameName = state . frameName ;
468- }
469-
470- return JSON . stringify ( stateObject , null , 2 ) ;
471- }
472-
473419 /**
474420 * Get current debug state
475421 */
0 commit comments