@@ -148,11 +148,6 @@ export class LoggingDebugAdapterTracker implements vscode.DebugAdapterTracker {
148148 } ;
149149 } ;
150150
151- type BreakpointBodyLike = {
152- source ?: { path ?: string } ;
153- line ?: number ;
154- } ;
155-
156151 try {
157152 const msg = rawMsg as DebugProtocol . ProtocolMessage ;
158153 const eventMsg = msg as DebugProtocol . Event ;
@@ -163,15 +158,13 @@ export class LoggingDebugAdapterTracker implements vscode.DebugAdapterTracker {
163158
164159 const normalizePath = ( p : string ) : string => {
165160 try {
166- // If adapter sends a URI-like path, parse it
167- if ( p . startsWith ( "file://" ) || p . includes ( "://" ) ) {
168- return vscode . Uri . parse ( p ) . fsPath ;
169- }
170- // Otherwise treat as filesystem path
171- return vscode . Uri . file ( p ) . fsPath ;
161+ return vscode . Uri . parse ( p , true ) . fsPath ;
172162 } catch {
173- // Fallback: return raw
174- return p ;
163+ try {
164+ return vscode . Uri . file ( p ) . fsPath ;
165+ } catch {
166+ return p ;
167+ }
175168 }
176169 } ;
177170
@@ -200,10 +193,8 @@ export class LoggingDebugAdapterTracker implements vscode.DebugAdapterTracker {
200193
201194 for ( const bp of breakpoints ) {
202195 const loc = bp . location ;
203- if ( ! loc ) {
204- continue ;
205- }
206- if ( loc . uri . fsPath !== normalizePath ( sourcePath ) ) {
196+
197+ if ( normalizePath ( loc . uri . fsPath ) !== normalizePath ( sourcePath ) ) {
207198 continue ;
208199 }
209200 if ( loc . range . start . line !== bpLine0 ) {
@@ -220,24 +211,33 @@ export class LoggingDebugAdapterTracker implements vscode.DebugAdapterTracker {
220211
221212 // Case B: explicit "breakpoint" event that carries source+line info
222213 if ( eventMsg . event === "breakpoint" && eventMsg . body ) {
223- const body = eventMsg . body as BreakpointBodyLike ;
224- const sourcePath = body . source ?. path ;
225- const line = body . line ;
214+ const bpEvent = eventMsg as DebugProtocol . BreakpointEvent ;
215+ const dapBp = bpEvent . body ?. breakpoint ;
216+ if ( ! dapBp ) {
217+ return ;
218+ }
219+
220+ // If the adapter already marked this breakpoint as verified/resolved,
221+ // there's no need to re-add it.
222+ if ( dapBp . verified === true ) {
223+ return ;
224+ }
225+
226+ const sourcePath = dapBp . source ?. path ;
227+ const line = dapBp . line ;
226228 if ( ! sourcePath || typeof line !== "number" ) {
227229 return ;
228230 }
229231
230232 const bpLine0 = line - 1 ;
231233 const breakpoints = vscode . debug . breakpoints . filter (
232- b => b instanceof vscode . SourceBreakpoint
234+ b => ! ! ( b as vscode . SourceBreakpoint ) . location
233235 ) as vscode . SourceBreakpoint [ ] ;
234236
235237 for ( const bp of breakpoints ) {
236238 const loc = bp . location ;
237- if ( ! loc ) {
238- continue ;
239- }
240- if ( loc . uri . fsPath !== normalizePath ( sourcePath ) ) {
239+
240+ if ( normalizePath ( loc . uri . fsPath ) !== normalizePath ( sourcePath ) ) {
241241 continue ;
242242 }
243243 if ( loc . range . start . line !== bpLine0 ) {
@@ -250,9 +250,12 @@ export class LoggingDebugAdapterTracker implements vscode.DebugAdapterTracker {
250250 }
251251 return ;
252252 }
253- } catch ( err ) {
254- // eslint-disable-next-line no-console
255- this . logger ?. error ( Error ( 'Breakpoint fallback error' , { cause : err } ) ;
253+ } catch ( err : unknown ) {
254+ try {
255+ this . logger ?. error ( new Error ( "Breakpoint fallback error" , { cause : err } ) ) ;
256+ } catch {
257+ this . logger ?. error ( "Breakpoint fallback error: " + String ( err ) ) ;
258+ }
256259 }
257260 }
258261
0 commit comments