debugger: Make UI a bit more dense (#27429)

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-03-25 17:58:51 +01:00 committed by GitHub
parent 954a56ce0c
commit f9212a001e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 109 additions and 96 deletions

View file

@ -24,7 +24,7 @@ use ui::prelude::*;
use util::ResultExt; use util::ResultExt;
use workspace::{ use workspace::{
dock::{DockPosition, Panel, PanelEvent}, dock::{DockPosition, Panel, PanelEvent},
pane, ClearBreakpoints, Continue, Disconnect, Pane, Pause, Restart, StepBack, StepInto, pane, ClearAllBreakpoints, Continue, Disconnect, Pane, Pause, Restart, StepBack, StepInto,
StepOut, StepOver, Stop, ToggleIgnoreBreakpoints, Workspace, StepOut, StepOver, Stop, ToggleIgnoreBreakpoints, Workspace,
}; };
@ -174,7 +174,7 @@ impl DebugPanel {
workspace.update_in(cx, |workspace, window, cx| { workspace.update_in(cx, |workspace, window, cx| {
let debug_panel = DebugPanel::new(workspace, window, cx); let debug_panel = DebugPanel::new(workspace, window, cx);
workspace.register_action(|workspace, _: &ClearBreakpoints, _, cx| { workspace.register_action(|workspace, _: &ClearAllBreakpoints, _, cx| {
workspace.project().read(cx).breakpoint_store().update( workspace.project().read(cx).breakpoint_store().update(
cx, cx,
|breakpoint_store, cx| { |breakpoint_store, cx| {

View file

@ -16,8 +16,8 @@ use settings::Settings;
use stack_frame_list::StackFrameList; use stack_frame_list::StackFrameList;
use ui::{ use ui::{
div, h_flex, v_flex, ActiveTheme, AnyElement, App, Button, ButtonCommon, Clickable, Context, div, h_flex, v_flex, ActiveTheme, AnyElement, App, Button, ButtonCommon, Clickable, Context,
ContextMenu, Disableable, DropdownMenu, FluentBuilder, IconButton, IconName, IconSize, ContextMenu, Disableable, Divider, DropdownMenu, FluentBuilder, IconButton, IconName, IconSize,
Indicator, InteractiveElement, IntoElement, ParentElement, Render, SharedString, Indicator, InteractiveElement, IntoElement, Label, ParentElement, Render, SharedString,
StatefulInteractiveElement, Styled, Tooltip, Window, StatefulInteractiveElement, Styled, Tooltip, Window,
}; };
use util::ResultExt; use util::ResultExt;
@ -85,9 +85,10 @@ impl Render for RunningState {
.justify_between() .justify_between()
.child( .child(
h_flex() h_flex()
.p_1() .px_1()
.py_0p5()
.w_full() .w_full()
.gap_2() .gap_1()
.map(|this| { .map(|this| {
if thread_status == ThreadStatus::Running { if thread_status == ThreadStatus::Running {
this.child( this.child(
@ -95,7 +96,7 @@ impl Render for RunningState {
"debug-pause", "debug-pause",
IconName::DebugPause, IconName::DebugPause,
) )
.icon_size(IconSize::Small) .icon_size(IconSize::XSmall)
.on_click(cx.listener(|this, _, _window, cx| { .on_click(cx.listener(|this, _, _window, cx| {
this.pause_thread(cx); this.pause_thread(cx);
})) }))
@ -109,7 +110,7 @@ impl Render for RunningState {
"debug-continue", "debug-continue",
IconName::DebugContinue, IconName::DebugContinue,
) )
.icon_size(IconSize::Small) .icon_size(IconSize::XSmall)
.on_click(cx.listener(|this, _, _window, cx| { .on_click(cx.listener(|this, _, _window, cx| {
this.continue_thread(cx) this.continue_thread(cx)
})) }))
@ -120,61 +121,9 @@ impl Render for RunningState {
) )
} }
}) })
.when(
capabilities.supports_step_back.unwrap_or(false),
|this| {
this.child(
IconButton::new(
"debug-step-back",
IconName::DebugStepBack,
)
.icon_size(IconSize::Small)
.on_click(cx.listener(|this, _, _window, cx| {
this.step_back(cx);
}))
.disabled(thread_status != ThreadStatus::Stopped)
.tooltip(move |window, cx| {
Tooltip::text("Step back")(window, cx)
}),
)
},
)
.child(
IconButton::new("debug-step-over", IconName::DebugStepOver)
.icon_size(IconSize::Small)
.on_click(cx.listener(|this, _, _window, cx| {
this.step_over(cx);
}))
.disabled(thread_status != ThreadStatus::Stopped)
.tooltip(move |window, cx| {
Tooltip::text("Step over")(window, cx)
}),
)
.child(
IconButton::new("debug-step-in", IconName::DebugStepInto)
.icon_size(IconSize::Small)
.on_click(cx.listener(|this, _, _window, cx| {
this.step_in(cx);
}))
.disabled(thread_status != ThreadStatus::Stopped)
.tooltip(move |window, cx| {
Tooltip::text("Step in")(window, cx)
}),
)
.child(
IconButton::new("debug-step-out", IconName::DebugStepOut)
.icon_size(IconSize::Small)
.on_click(cx.listener(|this, _, _window, cx| {
this.step_out(cx);
}))
.disabled(thread_status != ThreadStatus::Stopped)
.tooltip(move |window, cx| {
Tooltip::text("Step out")(window, cx)
}),
)
.child( .child(
IconButton::new("debug-restart", IconName::DebugRestart) IconButton::new("debug-restart", IconName::DebugRestart)
.icon_size(IconSize::Small) .icon_size(IconSize::XSmall)
.on_click(cx.listener(|this, _, _window, cx| { .on_click(cx.listener(|this, _, _window, cx| {
this.restart_session(cx); this.restart_session(cx);
})) }))
@ -189,7 +138,7 @@ impl Render for RunningState {
) )
.child( .child(
IconButton::new("debug-stop", IconName::DebugStop) IconButton::new("debug-stop", IconName::DebugStop)
.icon_size(IconSize::Small) .icon_size(IconSize::XSmall)
.on_click(cx.listener(|this, _, _window, cx| { .on_click(cx.listener(|this, _, _window, cx| {
this.stop_thread(cx); this.stop_thread(cx);
})) }))
@ -214,7 +163,7 @@ impl Render for RunningState {
"debug-disconnect", "debug-disconnect",
IconName::DebugDisconnect, IconName::DebugDisconnect,
) )
.icon_size(IconSize::Small) .icon_size(IconSize::XSmall)
.on_click(cx.listener(|this, _, _window, cx| { .on_click(cx.listener(|this, _, _window, cx| {
this.disconnect_client(cx); this.disconnect_client(cx);
})) }))
@ -222,12 +171,62 @@ impl Render for RunningState {
thread_status == ThreadStatus::Exited thread_status == ThreadStatus::Exited
|| thread_status == ThreadStatus::Ended, || thread_status == ThreadStatus::Ended,
) )
.tooltip( .tooltip(Tooltip::text("Disconnect")),
move |window, cx| {
Tooltip::text("Disconnect")(window, cx)
},
),
) )
.child(Divider::vertical())
.when(
capabilities.supports_step_back.unwrap_or(false),
|this| {
this.child(
IconButton::new(
"debug-step-back",
IconName::DebugStepBack,
)
.icon_size(IconSize::XSmall)
.on_click(cx.listener(|this, _, _window, cx| {
this.step_back(cx);
}))
.disabled(thread_status != ThreadStatus::Stopped)
.tooltip(move |window, cx| {
Tooltip::text("Step back")(window, cx)
}),
)
},
)
.child(
IconButton::new("debug-step-over", IconName::DebugStepOver)
.icon_size(IconSize::XSmall)
.on_click(cx.listener(|this, _, _window, cx| {
this.step_over(cx);
}))
.disabled(thread_status != ThreadStatus::Stopped)
.tooltip(move |window, cx| {
Tooltip::text("Step over")(window, cx)
}),
)
.child(
IconButton::new("debug-step-in", IconName::DebugStepInto)
.icon_size(IconSize::XSmall)
.on_click(cx.listener(|this, _, _window, cx| {
this.step_in(cx);
}))
.disabled(thread_status != ThreadStatus::Stopped)
.tooltip(move |window, cx| {
Tooltip::text("Step in")(window, cx)
}),
)
.child(
IconButton::new("debug-step-out", IconName::DebugStepOut)
.icon_size(IconSize::XSmall)
.on_click(cx.listener(|this, _, _window, cx| {
this.step_out(cx);
}))
.disabled(thread_status != ThreadStatus::Stopped)
.tooltip(move |window, cx| {
Tooltip::text("Step out")(window, cx)
}),
)
.child(Divider::vertical())
.child( .child(
IconButton::new( IconButton::new(
"debug-ignore-breakpoints", "debug-ignore-breakpoints",
@ -237,7 +236,7 @@ impl Render for RunningState {
IconName::DebugIgnoreBreakpoints IconName::DebugIgnoreBreakpoints
}, },
) )
.icon_size(IconSize::Small) .icon_size(IconSize::XSmall)
.on_click(cx.listener(|this, _, _window, cx| { .on_click(cx.listener(|this, _, _window, cx| {
this.toggle_ignore_breakpoints(cx); this.toggle_ignore_breakpoints(cx);
})) }))
@ -252,33 +251,47 @@ impl Render for RunningState {
), ),
), ),
) )
//.child(h_flex())
.child( .child(
h_flex().p_1().mx_2().w_3_4().justify_end().child( h_flex()
DropdownMenu::new( .px_1()
("thread-list", self.session_id.0), .py_0p5()
selected_thread_name, .gap_2()
ContextMenu::build(window, cx, move |mut this, _, _| { .w_3_4()
for (thread, _) in threads { .justify_end()
let state = state.clone(); .child(Label::new("Thread:"))
let thread_id = thread.id; .child(
this = DropdownMenu::new(
this.entry(thread.name, None, move |_, cx| { ("thread-list", self.session_id.0),
state.update(cx, |state, cx| { selected_thread_name,
state.select_thread( ContextMenu::build(
ThreadId(thread_id), window,
cx, cx,
); move |mut this, _, _| {
}); for (thread, _) in threads {
}); let state = state.clone();
} let thread_id = thread.id;
this this = this.entry(
}), thread.name,
) None,
.disabled( move |_, cx| {
has_no_threads || thread_status != ThreadStatus::Stopped, state.update(cx, |state, cx| {
state.select_thread(
ThreadId(thread_id),
cx,
);
});
},
);
}
this
},
),
)
.disabled(
has_no_threads
|| thread_status != ThreadStatus::Stopped,
),
), ),
),
), ),
) )
.child( .child(

View file

@ -1385,7 +1385,7 @@ async fn test_unsetting_breakpoints_on_clear_breakpoint_action(
}) })
.await; .await;
cx.dispatch_action(workspace::ClearBreakpoints); cx.dispatch_action(workspace::ClearAllBreakpoints);
cx.run_until_parked(); cx.run_until_parked();
let shutdown_session = project.update(cx, |project, cx| { let shutdown_session = project.update(cx, |project, cx| {

View file

@ -142,7 +142,7 @@ actions!(
StepBack, StepBack,
Stop, Stop,
ToggleIgnoreBreakpoints, ToggleIgnoreBreakpoints,
ClearBreakpoints ClearAllBreakpoints
] ]
); );