From 5f452dbca2d71aa8c81eed641437443d2e9e7c1b Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Wed, 21 May 2025 20:59:44 -0400 Subject: [PATCH] debugger: Add a couple more keybindings (#31103) - Add missing handler for `debugger::Continue` so `f5` works - Add bindings based on VS Code for `debugger::Restart` and `debug_panel::ToggleFocus` - Remove breakpoint-related buttons from the debug panel's top strip, and surface the bindings for `editor::ToggleBreakpoint` in gutter tooltip instead Release Notes: - Debugger Beta: Added keybindings for `debugger::Continue`, `debugger::Restart`, and `debug_panel::ToggleFocus`. - Debugger Beta: Removed breakpoint-related buttons from the top of the debug panel. - Compatibility note: on Linux, `ctrl-shift-d` is now bound to `debug_panel::ToggleFocus` by default, instead of `editor::DuplicateLineDown`. --- assets/keymaps/default-linux.json | 3 +- assets/keymaps/default-macos.json | 2 + crates/debugger_ui/src/debugger_panel.rs | 49 ------------------------ crates/debugger_ui/src/debugger_ui.rs | 11 ++++++ crates/editor/src/editor.rs | 29 ++++++++------ 5 files changed, 32 insertions(+), 62 deletions(-) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 43f00af640a16fa9c7857186653d32758937a5f7..67761f0c3c64da3d0a9ebe2c753f7b8f5c25e90f 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -33,6 +33,7 @@ "f4": "debugger::Start", "f5": "debugger::Continue", "shift-f5": "debugger::Stop", + "ctrl-shift-f5": "debugger::Restart", "f6": "debugger::Pause", "f7": "debugger::StepOver", "cmd-f11": "debugger::StepInto", @@ -558,6 +559,7 @@ "ctrl-shift-e": "project_panel::ToggleFocus", "ctrl-shift-b": "outline_panel::ToggleFocus", "ctrl-shift-g": "git_panel::ToggleFocus", + "ctrl-shift-d": "debug_panel::ToggleFocus", "ctrl-?": "agent::ToggleFocus", "alt-save": "workspace::SaveAll", "ctrl-alt-s": "workspace::SaveAll", @@ -595,7 +597,6 @@ { "context": "Editor", "bindings": { - "ctrl-shift-d": "editor::DuplicateLineDown", "ctrl-shift-j": "editor::JoinLines", "ctrl-alt-backspace": "editor::DeleteToPreviousSubwordStart", "ctrl-alt-h": "editor::DeleteToPreviousSubwordStart", diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index 662b8034f4fffc3e98ebaef4b66af9f902784879..b0811f7d3427493d39ea25b09d89ae2dc0b0ca1c 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -17,6 +17,7 @@ "f4": "debugger::Start", "f5": "debugger::Continue", "shift-f5": "debugger::Stop", + "shift-cmd-f5": "debugger::Restart", "f6": "debugger::Pause", "f7": "debugger::StepOver", "f11": "debugger::StepInto", @@ -624,6 +625,7 @@ "cmd-shift-e": "project_panel::ToggleFocus", "cmd-shift-b": "outline_panel::ToggleFocus", "ctrl-shift-g": "git_panel::ToggleFocus", + "cmd-shift-d": "debug_panel::ToggleFocus", "cmd-?": "agent::ToggleFocus", "cmd-alt-s": "workspace::SaveAll", "cmd-k m": "language_selector::Toggle", diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index 8dd11ddbf08fde86da7ec5bcf0ed4287570bac32..60ee86e5dac319d359007504c8ba074bf2b87972 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -752,55 +752,6 @@ impl DebugPanel { }), ) .child(Divider::vertical()) - .child( - IconButton::new( - "debug-enable-breakpoint", - IconName::DebugDisabledBreakpoint, - ) - .icon_size(IconSize::XSmall) - .shape(ui::IconButtonShape::Square) - .disabled(thread_status != ThreadStatus::Stopped), - ) - .child( - IconButton::new( - "debug-disable-breakpoint", - IconName::CircleOff, - ) - .icon_size(IconSize::XSmall) - .shape(ui::IconButtonShape::Square) - .disabled(thread_status != ThreadStatus::Stopped), - ) - .child( - IconButton::new( - "debug-disable-all-breakpoints", - IconName::BugOff, - ) - .icon_size(IconSize::XSmall) - .shape(ui::IconButtonShape::Square) - .disabled( - thread_status == ThreadStatus::Exited - || thread_status == ThreadStatus::Ended, - ) - .on_click(window.listener_for( - &running_state, - |this, _, _window, cx| { - this.toggle_ignore_breakpoints(cx); - }, - )) - .tooltip({ - let focus_handle = focus_handle.clone(); - move |window, cx| { - Tooltip::for_action_in( - "Disable all breakpoints", - &ToggleIgnoreBreakpoints, - &focus_handle, - window, - cx, - ) - } - }), - ) - .child(Divider::vertical()) .child( IconButton::new("debug-restart", IconName::DebugRestart) .icon_size(IconSize::XSmall) diff --git a/crates/debugger_ui/src/debugger_ui.rs b/crates/debugger_ui/src/debugger_ui.rs index ef8621c33da1cd9250d3ccf9e4f992e8679616f5..528a687af70269d6b1a22260dc9a42b0828d13a9 100644 --- a/crates/debugger_ui/src/debugger_ui.rs +++ b/crates/debugger_ui/src/debugger_ui.rs @@ -95,6 +95,17 @@ pub fn init(cx: &mut App) { } } }) + .register_action(|workspace, _: &Continue, _, cx| { + if let Some(debug_panel) = workspace.panel::(cx) { + if let Some(active_item) = debug_panel.read_with(cx, |panel, cx| { + panel + .active_session() + .map(|session| session.read(cx).running_state().clone()) + }) { + active_item.update(cx, |item, cx| item.continue_thread(cx)) + } + } + }) .register_action(|workspace, _: &StepInto, _, cx| { if let Some(debug_panel) = workspace.panel::(cx) { if let Some(active_item) = debug_panel.read_with(cx, |panel, cx| { diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 6b935aeb4d6359fabfb4d95ba57a1326684b172a..0e8b01292ff9f5f48635a4fd4e252afc032f93c9 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -7266,24 +7266,22 @@ impl Editor { ..Default::default() }; let primary_action_text = if breakpoint.is_disabled() { - "enable" + "Enable breakpoint" } else if is_phantom && !collides_with_existing { - "set" + "Set breakpoint" } else { - "unset" + "Unset breakpoint" }; - let mut primary_text = format!("Click to {primary_action_text}"); - if collides_with_existing && !breakpoint.is_disabled() { - use std::fmt::Write; - write!(primary_text, ", {alt_as_text}-click to disable").ok(); - } - let primary_text = SharedString::from(primary_text); let focus_handle = self.focus_handle.clone(); let meta = if is_rejected { - "No executable code is associated with this line." + SharedString::from("No executable code is associated with this line.") + } else if collides_with_existing && !breakpoint.is_disabled() { + SharedString::from(format!( + "{alt_as_text}-click to disable,\nright-click for more options." + )) } else { - "Right-click for more options." + SharedString::from("Right-click for more options.") }; IconButton::new(("breakpoint_indicator", row.0 as usize), icon) .icon_size(IconSize::XSmall) @@ -7322,7 +7320,14 @@ impl Editor { ); })) .tooltip(move |window, cx| { - Tooltip::with_meta_in(primary_text.clone(), None, meta, &focus_handle, window, cx) + Tooltip::with_meta_in( + primary_action_text, + Some(&ToggleBreakpoint), + meta.clone(), + &focus_handle, + window, + cx, + ) }) }