Skip to content

Commit 8102c19

Browse files
committed
Streamline DAP methods for breakpoint manipulation
1 parent e97e26c commit 8102c19

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

crates/ark/src/console_annotate.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -897,9 +897,7 @@ pub unsafe extern "C-unwind" fn ps_annotate_source(code: SEXP, uri: SEXP) -> any
897897
};
898898

899899
// Notify frontend about any breakpoints marked invalid during annotation
900-
if let Some((_, breakpoints)) = dap_guard.breakpoints.get(&uri) {
901-
dap_guard.notify_invalid_breakpoints(breakpoints);
902-
}
900+
dap_guard.notify_invalid_breakpoints(&uri);
903901

904902
// Remove disabled breakpoints. Their verification state is now stale since
905903
// they weren't injected during this annotation. If the user re-enables

crates/ark/src/dap/dap.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,13 @@ impl Dap {
424424

425425
/// Notify the frontend about breakpoints that were marked invalid during annotation.
426426
/// Sends a `BreakpointState` event with verified=false and a message for each.
427-
pub fn notify_invalid_breakpoints(&self, breakpoints: &[Breakpoint]) {
427+
pub fn notify_invalid_breakpoints(&self, uri: &Url) {
428428
let Some(tx) = &self.backend_events_tx else {
429429
return;
430430
};
431+
let Some((_, breakpoints)) = self.breakpoints.get(uri) else {
432+
return;
433+
};
431434

432435
for bp in breakpoints {
433436
let BreakpointState::Invalid(reason) = &bp.state else {
@@ -443,6 +446,14 @@ impl Dap {
443446
}
444447
}
445448

449+
/// Remove disabled breakpoints for a given URI.
450+
pub fn remove_disabled_breakpoints(&mut self, uri: &Url) {
451+
let Some((_, bps)) = self.breakpoints.get_mut(uri) else {
452+
return;
453+
};
454+
bps.retain(|bp| !matches!(bp.state, BreakpointState::Disabled));
455+
}
456+
446457
pub(crate) fn is_breakpoint_enabled(&self, uri: &Url, id: String) -> bool {
447458
let Some((_, breakpoints)) = self.breakpoints.get(uri) else {
448459
return false;

crates/ark/src/interface.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ 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;
105104
use crate::dap::dap::DapBackendEvent;
106105
use crate::dap::Dap;
107106
use crate::errors::stack_overflow_occurred;
@@ -1445,20 +1444,11 @@ impl RMain {
14451444
},
14461445
}
14471446

1448-
// Notify frontend about any breakpoints marked invalid during annotation
1447+
// Notify frontend about any breakpoints marked invalid during annotation.
1448+
// Remove disabled breakpoints.
14491449
if let Some(uri) = &uri {
1450-
if let Some((_, bps)) = dap_guard.breakpoints.get(uri) {
1451-
dap_guard.notify_invalid_breakpoints(bps);
1452-
}
1453-
}
1454-
1455-
// Remove disabled breakpoints. Their verification state is now stale since
1456-
// they weren't injected during this annotation. If the user re-enables
1457-
// them, they'll be treated as new unverified breakpoints.
1458-
if let Some(uri) = &uri {
1459-
if let Some((_, bps)) = dap_guard.breakpoints.get_mut(uri) {
1460-
bps.retain(|bp| !matches!(bp.state, BreakpointState::Disabled));
1461-
}
1450+
dap_guard.notify_invalid_breakpoints(uri);
1451+
dap_guard.remove_disabled_breakpoints(uri);
14621452
}
14631453

14641454
drop(dap_guard);

0 commit comments

Comments
 (0)