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:
Cole Miller 2025-05-19 17:45:37 +02:00 committed by GitHub
parent d9f12879e2
commit e48daa92c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 57 additions and 19 deletions

View file

@ -81,6 +81,10 @@ impl RunningState {
pub(crate) fn thread_id(&self) -> Option<ThreadId> {
self.thread_id
}
pub(crate) fn active_pane(&self) -> Option<&Entity<Pane>> {
self.active_pane.as_ref()
}
}
impl Render for RunningState {
@ -502,20 +506,15 @@ impl DebugTerminal {
impl gpui::Render for DebugTerminal {
fn render(&mut self, _window: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
if let Some(terminal) = self.terminal.clone() {
terminal.into_any_element()
} else {
div().track_focus(&self.focus_handle).into_any_element()
}
div()
.size_full()
.track_focus(&self.focus_handle)
.children(self.terminal.clone())
}
}
impl Focusable for DebugTerminal {
fn focus_handle(&self, cx: &App) -> FocusHandle {
if let Some(terminal) = self.terminal.as_ref() {
return terminal.focus_handle(cx);
} else {
self.focus_handle.clone()
}
fn focus_handle(&self, _cx: &App) -> FocusHandle {
self.focus_handle.clone()
}
}