@@ -254,6 +254,7 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
254254 const uri = schemas . includes ( scheme ) ? vscode . Uri . parse ( filePath ) : vscode . Uri . file ( filePath ) ;
255255 const fileUri = await convertClientPathToDebugger ( uri , this . _namespace ) ;
256256 const [ , fileName ] = fileUri . match ( / \| ( [ ^ | ] + ) $ / ) ;
257+ const languageServer : boolean = vscode . extensions . getExtension ( "intersystems.language-server" ) ?. isActive ?? false ;
257258
258259 const currentList = await this . _connection . sendBreakpointListCommand ( ) ;
259260 currentList . breakpoints
@@ -294,34 +295,57 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
294295 ) {
295296 // This breakpoint is in a method
296297 const currentdoc = await vscode . workspace . openTextDocument ( uri ) ;
297- for (
298- let methodlinenum = currentSymbol . selectionRange . start . line ;
299- methodlinenum <= currentSymbol . range . end . line ;
300- methodlinenum ++
301- ) {
302- // Find the offset of this breakpoint in the method
303- const methodlinetext : string = currentdoc . lineAt ( methodlinenum ) . text . trim ( ) ;
304- if ( methodlinetext . endsWith ( "{" ) ) {
305- // This is the last line of the method definition, so count from here
306- if ( breakpoint . condition ) {
307- return new xdebug . ClassConditionalBreakpoint (
308- breakpoint . condition ,
309- fileUri ,
310- line ,
311- currentSymbol . name ,
312- line - methodlinenum - 1 ,
313- breakpoint . hitCondition
314- ) ;
315- } else {
316- return new xdebug . ClassLineBreakpoint (
317- fileUri ,
318- line ,
319- currentSymbol . name ,
320- line - methodlinenum - 1 ,
321- breakpoint . hitCondition
322- ) ;
298+ if ( languageServer ) {
299+ // selectionRange.start.line is the method definition line
300+ for (
301+ let methodlinenum = currentSymbol . selectionRange . start . line ;
302+ methodlinenum <= currentSymbol . range . end . line ;
303+ methodlinenum ++
304+ ) {
305+ // Find the offset of this breakpoint in the method
306+ const methodlinetext : string = currentdoc . lineAt ( methodlinenum ) . text . trim ( ) ;
307+ if ( methodlinetext . endsWith ( "{" ) ) {
308+ // This is the last line of the method definition, so count from here
309+ if ( breakpoint . condition ) {
310+ return new xdebug . ClassConditionalBreakpoint (
311+ breakpoint . condition ,
312+ fileUri ,
313+ line ,
314+ currentSymbol . name ,
315+ line - methodlinenum - 1 ,
316+ breakpoint . hitCondition
317+ ) ;
318+ } else {
319+ return new xdebug . ClassLineBreakpoint (
320+ fileUri ,
321+ line ,
322+ currentSymbol . name ,
323+ line - methodlinenum - 1 ,
324+ breakpoint . hitCondition
325+ ) ;
326+ }
323327 }
324328 }
329+ } else {
330+ // selectionRange.start.line is the start of the method code so count from there
331+ if ( breakpoint . condition ) {
332+ return new xdebug . ClassConditionalBreakpoint (
333+ breakpoint . condition ,
334+ fileUri ,
335+ line ,
336+ currentSymbol . name ,
337+ line - currentSymbol . selectionRange . start . line ,
338+ breakpoint . hitCondition
339+ ) ;
340+ } else {
341+ return new xdebug . ClassLineBreakpoint (
342+ fileUri ,
343+ line ,
344+ currentSymbol . name ,
345+ line - currentSymbol . selectionRange . start . line ,
346+ breakpoint . hitCondition
347+ ) ;
348+ }
325349 }
326350 }
327351 } else if ( filePath . endsWith ( "mac" ) || filePath . endsWith ( "int" ) ) {
@@ -345,7 +369,7 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
345369 }
346370 }
347371 } )
348- ) ;
372+ ) . then ( ( bps ) => bps . filter ( ( bp ) => typeof bp == "object" ) ) ;
349373
350374 const vscodeBreakpoints : DebugProtocol . Breakpoint [ ] = [ ] ;
351375 await Promise . all (
@@ -472,6 +496,7 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
472496 args : DebugProtocol . StackTraceArguments
473497 ) : Promise < void > {
474498 const stack = await this . _connection . sendStackGetCommand ( ) ;
499+ const languageServer : boolean = vscode . extensions . getExtension ( "intersystems.language-server" ) ?. isActive ?? false ;
475500
476501 const stackFrames = await Promise . all (
477502 stack . stack . map ( async ( stackFrame : xdebug . StackFrame , index ) : Promise < StackFrame > => {
@@ -503,18 +528,22 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
503528 }
504529 if ( currentSymbol !== undefined ) {
505530 const currentdoc = await vscode . workspace . openTextDocument ( fileUri ) ;
506- for (
507- let methodlinenum = currentSymbol . selectionRange . start . line ;
508- methodlinenum <= currentSymbol . range . end . line ;
509- methodlinenum ++
510- ) {
511- // Find the offset of this breakpoint in the method
512- const methodlinetext : string = currentdoc . lineAt ( methodlinenum ) . text . trim ( ) ;
513- if ( methodlinetext . endsWith ( "{" ) ) {
514- // This is the last line of the method definition, so count from here
515- line = methodlinenum + stackFrame . methodOffset + 1 ;
516- break ;
531+ if ( languageServer ) {
532+ for (
533+ let methodlinenum = currentSymbol . selectionRange . start . line ;
534+ methodlinenum <= currentSymbol . range . end . line ;
535+ methodlinenum ++
536+ ) {
537+ // Find the offset of this breakpoint in the method
538+ const methodlinetext : string = currentdoc . lineAt ( methodlinenum ) . text . trim ( ) ;
539+ if ( methodlinetext . endsWith ( "{" ) ) {
540+ // This is the last line of the method definition, so count from here
541+ line = methodlinenum + stackFrame . methodOffset + 1 ;
542+ break ;
543+ }
517544 }
545+ } else {
546+ line = currentSymbol . selectionRange . start . line + stackFrame . methodOffset ;
518547 }
519548 }
520549 }
0 commit comments