### DISCLAIMER > As of 6th March 2025, debugger is still in development. We plan to merge it behind a staff-only feature flag for staff use only, followed by non-public release and then finally a public one (akin to how Git panel release was handled). This is done to ensure the best experience when it gets released. ### END OF DISCLAIMER **The current state of the debugger implementation:** https://github.com/user-attachments/assets/c4deff07-80dd-4dc6-ad2e-0c252a478fe9 https://github.com/user-attachments/assets/e1ed2345-b750-4bb6-9c97-50961b76904f ---- All the todo's are in the following channel, so it's easier to work on this together: https://zed.dev/channel/zed-debugger-11370 If you are on Linux, you can use the following command to join the channel: ```cli zed https://zed.dev/channel/zed-debugger-11370 ``` ## Current Features - Collab - Breakpoints - Sync when you (re)join a project - Sync when you add/remove a breakpoint - Sync active debug line - Stack frames - Click on stack frame - View variables that belong to the stack frame - Visit the source file - Restart stack frame (if adapter supports this) - Variables - Loaded sources - Modules - Controls - Continue - Step back - Stepping granularity (configurable) - Step into - Stepping granularity (configurable) - Step over - Stepping granularity (configurable) - Step out - Stepping granularity (configurable) - Debug console - Breakpoints - Log breakpoints - line breakpoints - Persistent between zed sessions (configurable) - Multi buffer support - Toggle disable/enable all breakpoints - Stack frames - Click on stack frame - View variables that belong to the stack frame - Visit the source file - Show collapsed stack frames - Restart stack frame (if adapter supports this) - Loaded sources - View all used loaded sources if supported by adapter. - Modules - View all used modules (if adapter supports this) - Variables - Copy value - Copy name - Copy memory reference - Set value (if adapter supports this) - keyboard navigation - Debug Console - See logs - View output that was sent from debug adapter - Output grouping - Evaluate code - Updates the variable list - Auto completion - If not supported by adapter, we will show auto-completion for existing variables - Debug Terminal - Run custom commands and change env values right inside your Zed terminal - Attach to process (if adapter supports this) - Process picker - Controls - Continue - Step back - Stepping granularity (configurable) - Step into - Stepping granularity (configurable) - Step over - Stepping granularity (configurable) - Step out - Stepping granularity (configurable) - Disconnect - Restart - Stop - Warning when a debug session exited without hitting any breakpoint - Debug view to see Adapter/RPC log messages - Testing - Fake debug adapter - Fake requests & events --- Release Notes: - N/A --------- Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Co-authored-by: Anthony Eid <hello@anthonyeid.me> Co-authored-by: Anthony <anthony@zed.dev> Co-authored-by: Piotr Osiewicz <peterosiewicz@gmail.com> Co-authored-by: Piotr <piotr@zed.dev>
161 lines
4.3 KiB
Rust
161 lines
4.3 KiB
Rust
use gpui::{ClickEvent, Corner, CursorStyle, Entity, MouseButton};
|
|
|
|
use crate::{prelude::*, ContextMenu, PopoverMenu};
|
|
|
|
#[derive(IntoElement)]
|
|
pub struct DropdownMenu {
|
|
id: ElementId,
|
|
label: SharedString,
|
|
menu: Entity<ContextMenu>,
|
|
full_width: bool,
|
|
disabled: bool,
|
|
}
|
|
|
|
impl DropdownMenu {
|
|
pub fn new(
|
|
id: impl Into<ElementId>,
|
|
label: impl Into<SharedString>,
|
|
menu: Entity<ContextMenu>,
|
|
) -> Self {
|
|
Self {
|
|
id: id.into(),
|
|
label: label.into(),
|
|
menu,
|
|
full_width: false,
|
|
disabled: false,
|
|
}
|
|
}
|
|
|
|
pub fn full_width(mut self, full_width: bool) -> Self {
|
|
self.full_width = full_width;
|
|
self
|
|
}
|
|
}
|
|
|
|
impl Disableable for DropdownMenu {
|
|
fn disabled(mut self, disabled: bool) -> Self {
|
|
self.disabled = disabled;
|
|
self
|
|
}
|
|
}
|
|
|
|
impl RenderOnce for DropdownMenu {
|
|
fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {
|
|
PopoverMenu::new(self.id)
|
|
.full_width(self.full_width)
|
|
.menu(move |_window, _cx| Some(self.menu.clone()))
|
|
.trigger(
|
|
DropdownMenuTrigger::new(self.label)
|
|
.full_width(self.full_width)
|
|
.disabled(self.disabled),
|
|
)
|
|
.attach(Corner::BottomLeft)
|
|
}
|
|
}
|
|
|
|
#[derive(IntoElement)]
|
|
struct DropdownMenuTrigger {
|
|
label: SharedString,
|
|
full_width: bool,
|
|
selected: bool,
|
|
disabled: bool,
|
|
cursor_style: CursorStyle,
|
|
on_click: Option<Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>>,
|
|
}
|
|
|
|
impl DropdownMenuTrigger {
|
|
pub fn new(label: impl Into<SharedString>) -> Self {
|
|
Self {
|
|
label: label.into(),
|
|
full_width: false,
|
|
selected: false,
|
|
disabled: false,
|
|
cursor_style: CursorStyle::default(),
|
|
on_click: None,
|
|
}
|
|
}
|
|
|
|
pub fn full_width(mut self, full_width: bool) -> Self {
|
|
self.full_width = full_width;
|
|
self
|
|
}
|
|
}
|
|
|
|
impl Disableable for DropdownMenuTrigger {
|
|
fn disabled(mut self, disabled: bool) -> Self {
|
|
self.disabled = disabled;
|
|
self
|
|
}
|
|
}
|
|
|
|
impl Toggleable for DropdownMenuTrigger {
|
|
fn toggle_state(mut self, selected: bool) -> Self {
|
|
self.selected = selected;
|
|
self
|
|
}
|
|
}
|
|
|
|
impl Clickable for DropdownMenuTrigger {
|
|
fn on_click(mut self, handler: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static) -> Self {
|
|
self.on_click = Some(Box::new(handler));
|
|
self
|
|
}
|
|
|
|
fn cursor_style(mut self, cursor_style: CursorStyle) -> Self {
|
|
self.cursor_style = cursor_style;
|
|
self
|
|
}
|
|
}
|
|
|
|
impl RenderOnce for DropdownMenuTrigger {
|
|
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
|
|
let disabled = self.disabled;
|
|
|
|
h_flex()
|
|
.id("dropdown-menu-trigger")
|
|
.justify_between()
|
|
.rounded_sm()
|
|
.bg(cx.theme().colors().editor_background)
|
|
.pl_2()
|
|
.pr_1p5()
|
|
.py_0p5()
|
|
.gap_2()
|
|
.min_w_20()
|
|
.map(|el| {
|
|
if self.full_width {
|
|
el.w_full()
|
|
} else {
|
|
el.flex_none().w_auto()
|
|
}
|
|
})
|
|
.map(|el| {
|
|
if disabled {
|
|
el.cursor_not_allowed()
|
|
} else {
|
|
el.cursor_pointer()
|
|
}
|
|
})
|
|
.child(Label::new(self.label).color(if disabled {
|
|
Color::Disabled
|
|
} else {
|
|
Color::Default
|
|
}))
|
|
.child(
|
|
Icon::new(IconName::ChevronUpDown)
|
|
.size(IconSize::XSmall)
|
|
.color(if disabled {
|
|
Color::Disabled
|
|
} else {
|
|
Color::Muted
|
|
}),
|
|
)
|
|
.when_some(self.on_click.filter(|_| !disabled), |el, on_click| {
|
|
el.on_mouse_down(MouseButton::Left, |_, window, _| window.prevent_default())
|
|
.on_click(move |event, window, cx| {
|
|
cx.stop_propagation();
|
|
(on_click)(event, window, cx)
|
|
})
|
|
})
|
|
}
|
|
}
|