Skip to content

Commit a06a334

Browse files
committed
Fix issues with disabled breakpoints
1 parent 920dbba commit a06a334

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

crates/ark/src/console_annotate.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,11 @@ impl AnnotationRewriter<'_> {
716716
reason: InvalidReason,
717717
) {
718718
for bp in self.breakpoints.iter_mut() {
719-
let is_available =
720-
!self.consumed.contains(&bp.id) && !matches!(bp.state, BreakpointState::Invalid(_));
719+
let is_available = !self.consumed.contains(&bp.id) &&
720+
!matches!(
721+
bp.state,
722+
BreakpointState::Invalid(_) | BreakpointState::Disabled
723+
);
721724
if !is_available {
722725
continue;
723726
}
@@ -898,6 +901,13 @@ pub unsafe extern "C-unwind" fn ps_annotate_source(code: SEXP, uri: SEXP) -> any
898901
dap_guard.notify_invalid_breakpoints(breakpoints);
899902
}
900903

904+
// Remove disabled breakpoints. Their verification state is now stale since
905+
// they weren't injected during this annotation. If the user re-enables
906+
// them, they'll be treated as new unverified breakpoints.
907+
if let Some((_, breakpoints)) = dap_guard.breakpoints.get_mut(&uri) {
908+
breakpoints.retain(|bp| !matches!(bp.state, BreakpointState::Disabled));
909+
}
910+
901911
Ok(RObject::try_from(annotated)?.sexp)
902912
}
903913

crates/ark/src/dap/dap_server.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,15 @@ impl<R: Read, W: Write> DapServer<R, W> {
406406

407407
if let Some(old_bp) = old_by_line.remove(&line) {
408408
// Breakpoint already exists at this line
409-
let new_state = match old_bp.state {
410-
// This breakpoint used to be verified, was disabled, and is now back online
411-
BreakpointState::Disabled => BreakpointState::Verified,
409+
let (new_state, injected) = match old_bp.state {
410+
// This breakpoint used to be verified, was disabled, and is now back
411+
// online. Restore to Verified immediately.
412+
BreakpointState::Disabled => (BreakpointState::Verified, old_bp.injected),
413+
// Invalid breakpoints are reset to Unverified so they can be
414+
// re-validated on next source.
415+
BreakpointState::Invalid(_) => (BreakpointState::Unverified, false),
412416
// We preserve other states (verified or unverified)
413-
other => other,
417+
other => (other, old_bp.injected),
414418
};
415419

416420
breakpoints.push(Breakpoint {
@@ -419,8 +423,7 @@ impl<R: Read, W: Write> DapServer<R, W> {
419423
line: old_bp.line,
420424
original_line: line,
421425
state: new_state,
422-
// Preserve injected status from old breakpoint
423-
injected: old_bp.injected,
426+
injected,
424427
});
425428
} else {
426429
// New breakpoints always start as Unverified, until they get evaluated once

crates/ark/src/interface.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ use uuid::Uuid;
101101
use crate::console_annotate::annotate_input;
102102
use crate::console_debug::FrameInfoId;
103103
use crate::dap::dap::Breakpoint;
104+
use crate::dap::dap::BreakpointState;
104105
use crate::dap::dap::DapBackendEvent;
105106
use crate::dap::Dap;
106107
use crate::errors;
@@ -1464,6 +1465,16 @@ impl RMain {
14641465
dap_guard.notify_invalid_breakpoints(bps);
14651466
}
14661467
}
1468+
1469+
// Remove disabled breakpoints. Their verification state is now stale since
1470+
// they weren't injected during this annotation. If the user re-enables
1471+
// them, they'll be treated as new unverified breakpoints.
1472+
if let Some(uri) = &uri {
1473+
if let Some((_, bps)) = dap_guard.breakpoints.get_mut(uri) {
1474+
bps.retain(|bp| !matches!(bp.state, BreakpointState::Disabled));
1475+
}
1476+
}
1477+
14671478
drop(dap_guard);
14681479

14691480
// Evaluate first expression if there is one

0 commit comments

Comments
 (0)