From 28f0ba3381cc9ce161249af7858c03e62f400631 Mon Sep 17 00:00:00 2001
From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
Date: Fri, 28 Mar 2025 15:55:09 -0400
Subject: [PATCH] Debugger: Basic breakpoint improvements (#27687)
This PR does three things
- Right clicking within the gutter outside of the gutter fold area
bounds opens a breakpoint context menu
- Disabled breakpoints are now outline with the debugger accent color
instead of being fully colored at half opacity
- Clicking a breakpoint acts differently now
- Clicking a breakpoint while holding the platform modifier key will
disable/enable it
- Clicking a breakpoint hint while holding the platform modifier key
will set a disabled breakpoint
- Clicking a disabled breakpoint will enable it instead of deleting it
Release Notes:
- N/A
---
assets/icons/debug_disabled_breakpoint.svg | 1 +
.../icons/debug_disabled_log_breakpoint.svg | 1 +
crates/editor/src/editor.rs | 24 ++++++++++++-------
crates/editor/src/editor_tests.rs | 4 ++++
crates/editor/src/element.rs | 18 ++++++++++++++
crates/icons/src/icons.rs | 2 ++
.../project/src/debugger/breakpoint_store.rs | 3 ++-
7 files changed, 44 insertions(+), 9 deletions(-)
create mode 100644 assets/icons/debug_disabled_breakpoint.svg
create mode 100644 assets/icons/debug_disabled_log_breakpoint.svg
diff --git a/assets/icons/debug_disabled_breakpoint.svg b/assets/icons/debug_disabled_breakpoint.svg
new file mode 100644
index 0000000000000000000000000000000000000000..a7260ec04bee66c0b37dd92860ecf1666e445d23
--- /dev/null
+++ b/assets/icons/debug_disabled_breakpoint.svg
@@ -0,0 +1 @@
+
diff --git a/assets/icons/debug_disabled_log_breakpoint.svg b/assets/icons/debug_disabled_log_breakpoint.svg
new file mode 100644
index 0000000000000000000000000000000000000000..d0bb2c8e2b4fc33d303a3b877c9d0f30b9785cca
--- /dev/null
+++ b/assets/icons/debug_disabled_log_breakpoint.svg
@@ -0,0 +1 @@
+
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 6f193fae5540c360caa4115b206b4ab67e77def0..b4646af1b12c0868b1242c22582dbc15c0ff88ee 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -6279,20 +6279,22 @@ impl Editor {
cx: &mut Context,
) -> IconButton {
let (color, icon) = {
+ let icon = match (&breakpoint.kind, breakpoint.is_disabled()) {
+ (BreakpointKind::Standard, false) => ui::IconName::DebugBreakpoint,
+ (BreakpointKind::Log(_), false) => ui::IconName::DebugLogBreakpoint,
+ (BreakpointKind::Standard, true) => ui::IconName::DebugDisabledBreakpoint,
+ (BreakpointKind::Log(_), true) => ui::IconName::DebugDisabledLogBreakpoint,
+ };
+
let color = if self
.gutter_breakpoint_indicator
.is_some_and(|point| point.row() == row)
{
Color::Hint
- } else if breakpoint.is_disabled() {
- Color::Custom(Color::Debugger.color(cx).opacity(0.5))
} else {
Color::Debugger
};
- let icon = match &breakpoint.kind {
- BreakpointKind::Standard => ui::IconName::DebugBreakpoint,
- BreakpointKind::Log(_) => ui::IconName::DebugLogBreakpoint,
- };
+
(color, icon)
};
@@ -6306,12 +6308,18 @@ impl Editor {
.on_click(cx.listener({
let breakpoint = breakpoint.clone();
- move |editor, _e, window, cx| {
+ move |editor, event: &ClickEvent, window, cx| {
+ let edit_action = if event.modifiers().platform || breakpoint.is_disabled() {
+ BreakpointEditAction::InvertState
+ } else {
+ BreakpointEditAction::Toggle
+ };
+
window.focus(&editor.focus_handle(cx));
editor.edit_breakpoint_at_anchor(
position,
breakpoint.as_ref().clone(),
- BreakpointEditAction::Toggle,
+ edit_action,
cx,
);
}
diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs
index 3c21fd44939b754b9616c8da8bc01ea016501f8c..662f8e253503d238d49a4f0ed1f388a780f36fcb 100644
--- a/crates/editor/src/editor_tests.rs
+++ b/crates/editor/src/editor_tests.rs
@@ -17842,6 +17842,10 @@ async fn test_breakpoint_enabling_and_disabling(cx: &mut TestAppContext) {
editor.disable_breakpoint(&actions::DisableBreakpoint, window, cx);
editor.move_to_end(&MoveToEnd, window, cx);
editor.disable_breakpoint(&actions::DisableBreakpoint, window, cx);
+ // Disabling a breakpoint that doesn't exist should do nothing
+ editor.move_up(&MoveUp, window, cx);
+ editor.move_up(&MoveUp, window, cx);
+ editor.disable_breakpoint(&actions::DisableBreakpoint, window, cx);
});
let breakpoints = editor.update(cx, |editor, cx| {
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs
index 6d490f2fe66c445545a0436f749afefd00c6e27d..4762b9751d6d76fb5c256311fe48cc83a051fdaa 100644
--- a/crates/editor/src/element.rs
+++ b/crates/editor/src/element.rs
@@ -713,9 +713,27 @@ impl EditorElement {
window: &mut Window,
cx: &mut Context,
) {
+ if position_map.gutter_hitbox.is_hovered(window) {
+ let gutter_right_padding = editor.gutter_dimensions.right_padding;
+ let hitbox = &position_map.gutter_hitbox;
+
+ if event.position.x <= hitbox.bounds.right() - gutter_right_padding {
+ let point_for_position = position_map.point_for_position(event.position);
+ editor.set_breakpoint_context_menu(
+ point_for_position.previous_valid.row(),
+ None,
+ event.position,
+ window,
+ cx,
+ );
+ }
+ return;
+ }
+
if !position_map.text_hitbox.is_hovered(window) {
return;
}
+
let point_for_position = position_map.point_for_position(event.position);
mouse_context_menu::deploy_context_menu(
editor,
diff --git a/crates/icons/src/icons.rs b/crates/icons/src/icons.rs
index 8dfc1d7452e000843a8c714fa88acfc095321be3..ab0068f6757f5974bae8b59011395799512b3eb2 100644
--- a/crates/icons/src/icons.rs
+++ b/crates/icons/src/icons.rs
@@ -70,6 +70,8 @@ pub enum IconName {
CursorIBeam,
Dash,
DebugBreakpoint,
+ DebugDisabledBreakpoint,
+ DebugDisabledLogBreakpoint,
DebugIgnoreBreakpoints,
DebugPause,
DebugContinue,
diff --git a/crates/project/src/debugger/breakpoint_store.rs b/crates/project/src/debugger/breakpoint_store.rs
index 687825399704b2423f5013036694bd2e8fd75d04..421438532b03b3923a32a600c55dd82a655a1969 100644
--- a/crates/project/src/debugger/breakpoint_store.rs
+++ b/crates/project/src/debugger/breakpoint_store.rs
@@ -268,7 +268,8 @@ impl BreakpointStore {
bp.state = BreakpointState::Enabled;
}
} else {
- log::error!("Attempted to invert a breakpoint's state that doesn't exist ");
+ breakpoint.1.state = BreakpointState::Disabled;
+ breakpoint_set.breakpoints.push(breakpoint.clone());
}
}
BreakpointEditAction::EditLogMessage(log_message) => {