debugger: Remember focused item (#30722)
Release Notes: - Debugger Beta: the `debug panel: toggle focus` action now preserves the debug panel's focused item.
This commit is contained in:
parent
d9f12879e2
commit
e48daa92c0
4 changed files with 57 additions and 19 deletions
|
@ -69,15 +69,20 @@ pub struct DebugPanel {
|
|||
}
|
||||
|
||||
impl DebugPanel {
|
||||
pub fn new(workspace: &Workspace, cx: &mut Context<Workspace>) -> Entity<Self> {
|
||||
pub fn new(
|
||||
workspace: &Workspace,
|
||||
_window: &mut Window,
|
||||
cx: &mut Context<Workspace>,
|
||||
) -> Entity<Self> {
|
||||
cx.new(|cx| {
|
||||
let project = workspace.project().clone();
|
||||
let focus_handle = cx.focus_handle();
|
||||
|
||||
let debug_panel = Self {
|
||||
size: px(300.),
|
||||
sessions: vec![],
|
||||
active_session: None,
|
||||
focus_handle: cx.focus_handle(),
|
||||
focus_handle,
|
||||
project,
|
||||
workspace: workspace.weak_handle(),
|
||||
context_menu: None,
|
||||
|
@ -88,6 +93,24 @@ impl DebugPanel {
|
|||
})
|
||||
}
|
||||
|
||||
pub(crate) fn focus_active_item(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
let Some(session) = self.active_session.clone() else {
|
||||
return;
|
||||
};
|
||||
let Some(active_pane) = session
|
||||
.read(cx)
|
||||
.running_state()
|
||||
.read(cx)
|
||||
.active_pane()
|
||||
.cloned()
|
||||
else {
|
||||
return;
|
||||
};
|
||||
active_pane.update(cx, |pane, cx| {
|
||||
pane.focus_active_item(window, cx);
|
||||
});
|
||||
}
|
||||
|
||||
pub(crate) fn sessions(&self) -> Vec<Entity<DebugSession>> {
|
||||
self.sessions.clone()
|
||||
}
|
||||
|
@ -182,8 +205,8 @@ impl DebugPanel {
|
|||
cx: &mut AsyncWindowContext,
|
||||
) -> Task<Result<Entity<Self>>> {
|
||||
cx.spawn(async move |cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
let debug_panel = DebugPanel::new(workspace, cx);
|
||||
workspace.update_in(cx, |workspace, window, cx| {
|
||||
let debug_panel = DebugPanel::new(workspace, window, cx);
|
||||
|
||||
workspace.register_action(|workspace, _: &ClearAllBreakpoints, _, cx| {
|
||||
workspace.project().read(cx).breakpoint_store().update(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue