@@ -218,40 +218,51 @@ class PhpDebugSession extends vscode.DebugSession {
218218 /** This is called for each source file that has breakpoints with all the breakpoints in that file and whenever these change. */
219219 protected setBreakPointsRequest ( response : VSCodeDebugProtocol . SetBreakpointsResponse , args : VSCodeDebugProtocol . SetBreakpointsArguments ) {
220220 const file = path2uri ( args . source . path ) ;
221- const breakpoints : vscode . Breakpoint [ ] = [ ] ;
222221 const connections = Array . from ( this . _connections . values ( ) ) ;
223- return Promise . all ( connections . map ( connection =>
224- // clear breakpoints for this file
225- connection . sendBreakpointListCommand ( )
226- . then ( response => Promise . all (
227- response . breakpoints
228- . filter ( breakpoint => breakpoint . type === 'line' && breakpoint . fileUri === file )
229- . map ( breakpoint => breakpoint . remove ( ) )
230- ) )
231- // set them
232- . then ( ( ) => Promise . all ( args . lines . map ( line =>
233- connection . sendBreakpointSetCommand ( { type : 'line' , file, line} )
234- . then ( xdebugResponse => {
235- // only capture each breakpoint once (for the main connection)
236- if ( connection === this . _mainConnection ) {
237- breakpoints . push ( new vscode . Breakpoint ( true , line ) ) ;
238- }
239- } )
240- . catch ( error => {
241- // only capture each breakpoint once (for the main connection)
242- if ( connection === this . _mainConnection ) {
243- console . error ( 'breakpoint could not be set: ' , error ) ;
244- breakpoints . push ( new vscode . Breakpoint ( false , line ) ) ;
245- }
246- } )
247- ) ) )
248- ) ) . then ( ( ) => {
249- response . body = { breakpoints} ;
250- this . _breakpoints . set ( file , args . lines ) ;
251- this . sendResponse ( response ) ;
252- } ) . catch ( error => {
253- this . sendErrorResponse ( response , error . code , error . message ) ;
254- } ) ;
222+ let breakpoints : vscode . Breakpoint [ ] ;
223+ let breakpointsSetPromise : Promise < any > ;
224+ if ( connections . length === 0 ) {
225+ // if there are no connections yet, we cannot verify any breakpoint
226+ breakpoints = args . lines . map ( line => new vscode . Breakpoint ( false , line ) ) ;
227+ breakpointsSetPromise = Promise . resolve ( ) ;
228+ } else {
229+ breakpoints = [ ] ;
230+ breakpointsSetPromise = Promise . all ( connections . map ( connection =>
231+ // clear breakpoints for this file
232+ connection . sendBreakpointListCommand ( )
233+ . then ( response => Promise . all (
234+ response . breakpoints
235+ . filter ( breakpoint => breakpoint . type === 'line' && breakpoint . fileUri === file )
236+ . map ( breakpoint => breakpoint . remove ( ) )
237+ ) )
238+ // set them
239+ . then ( ( ) => Promise . all ( args . lines . map ( line =>
240+ connection . sendBreakpointSetCommand ( { type : 'line' , file, line} )
241+ . then ( xdebugResponse => {
242+ // only capture each breakpoint once (for the main connection)
243+ if ( connection === this . _mainConnection ) {
244+ breakpoints . push ( new vscode . Breakpoint ( true , line ) ) ;
245+ }
246+ } )
247+ . catch ( error => {
248+ // only capture each breakpoint once (for the main connection)
249+ if ( connection === this . _mainConnection ) {
250+ console . error ( 'breakpoint could not be set: ' , error ) ;
251+ breakpoints . push ( new vscode . Breakpoint ( false , line ) ) ;
252+ }
253+ } )
254+ ) ) )
255+ ) )
256+ }
257+ breakpointsSetPromise
258+ . then ( ( ) => {
259+ response . body = { breakpoints} ;
260+ this . _breakpoints . set ( file , args . lines ) ;
261+ this . sendResponse ( response ) ;
262+ } )
263+ . catch ( error => {
264+ this . sendErrorResponse ( response , error . code , error . message ) ;
265+ } ) ;
255266 }
256267
257268 /** This is called once after all line breakpoints have been set and whenever the breakpoints settings change */
0 commit comments