@@ -227,7 +227,7 @@ pub struct Dap {
227227 /// Whether R is stopped at an unexpected `browser()` prompt in notebook
228228 /// mode (no active debug session). Mutually exclusive with `is_debugging`.
229229 /// Used by the interrupt handler to decide whether to send a "Q" command.
230- /// `id_debugging ` and `is_stopped_at_browser ` could be folded into a single
230+ /// `is_debugging ` and `is_debugging_stdin ` could be folded into a single
231231 /// enum in the future.
232232 pub is_debugging_stdin : bool ,
233233
@@ -285,7 +285,7 @@ pub struct Dap {
285285
286286 /// IOPub sender for emitting DAP events as `debug_event` messages
287287 /// in notebook debugging mode (Jupyter Debug Protocol path).
288- iopub_tx : Option < Sender < IOPubMessage > > ,
288+ notebook_iopub_tx : Option < Sender < IOPubMessage > > ,
289289
290290 /// Sequence counter for IOPub DAP event messages.
291291 iopub_seq : i64 ,
@@ -314,7 +314,7 @@ impl Dap {
314314 current_variables_reference : 1 ,
315315 current_breakpoint_id : 1 ,
316316 comm_tx : None ,
317- iopub_tx : None ,
317+ notebook_iopub_tx : None ,
318318 iopub_seq : 0 ,
319319 r_request_tx,
320320 shared_self : None ,
@@ -388,7 +388,7 @@ impl Dap {
388388 let was_debugging = self . is_debugging ;
389389 self . is_debugging = false ;
390390
391- if was_debugging && ( self . is_connected || self . iopub_tx . is_some ( ) ) {
391+ if was_debugging && ( self . is_connected || self . notebook_iopub_tx . is_some ( ) ) {
392392 log:: trace!( "DAP: Sending `stop_debug` events" ) ;
393393
394394 if let Some ( comm_tx) = & self . comm_tx {
@@ -406,15 +406,15 @@ impl Dap {
406406 }
407407
408408 pub fn set_iopub_tx ( & mut self , tx : Sender < IOPubMessage > ) {
409- self . iopub_tx = Some ( tx) ;
409+ self . notebook_iopub_tx = Some ( tx) ;
410410 }
411411
412412 fn send_backend_event ( & mut self , event : DapBackendEvent ) {
413413 if let Some ( tx) = & self . backend_events_tx {
414414 tx. send ( event. clone ( ) ) . log_err ( ) ;
415415 }
416416
417- if let Some ( tx) = & self . iopub_tx {
417+ if let Some ( tx) = & self . notebook_iopub_tx {
418418 let dap_event = event. into_dap_event ( ) ;
419419 self . iopub_seq += 1 ;
420420
@@ -611,6 +611,8 @@ impl Dap {
611611 return ;
612612 } ;
613613
614+ // Collect events first: `bp_list` borrows from `self.breakpoints`,
615+ // which prevents calling `&mut self` methods like `send_backend_event()`.
614616 let mut events = Vec :: new ( ) ;
615617
616618 for bp in bp_list. iter_mut ( ) {
@@ -871,7 +873,7 @@ mod tests {
871873 current_breakpoint_id : 1 ,
872874 is_interrupting_for_debugger : false ,
873875 comm_tx : None ,
874- iopub_tx : None ,
876+ notebook_iopub_tx : None ,
875877 iopub_seq : 0 ,
876878 is_debugging_stdin : false ,
877879 r_request_tx,
@@ -985,7 +987,7 @@ mod tests {
985987 current_breakpoint_id : 1 ,
986988 is_interrupting_for_debugger : false ,
987989 comm_tx : None ,
988- iopub_tx : None ,
990+ notebook_iopub_tx : None ,
989991 iopub_seq : 0 ,
990992 is_debugging_stdin : false ,
991993 r_request_tx,
0 commit comments