debugger: Fix focus nits (#30547)

- Focus the console's query bar (if it exists) when focusing the console
- Fix incorrect focus handles used for the console and terminal at the
`Subview` level

Release Notes:

- N/A

Co-authored-by: Piotr <piotr@zed.dev>
Co-authored-by: Anthony <anthony@zed.dev>
This commit is contained in:
Cole Miller 2025-05-14 00:52:03 +02:00 committed by GitHub
parent f1fe505649
commit 2f26a860a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 14 deletions

View file

@ -119,7 +119,7 @@ impl Render for RunningState {
pub(crate) struct SubView {
inner: AnyView,
pane_focus_handle: FocusHandle,
item_focus_handle: FocusHandle,
kind: DebuggerPaneItem,
show_indicator: Box<dyn Fn(&App) -> bool>,
hovered: bool,
@ -127,7 +127,7 @@ pub(crate) struct SubView {
impl SubView {
pub(crate) fn new(
pane_focus_handle: FocusHandle,
item_focus_handle: FocusHandle,
view: AnyView,
kind: DebuggerPaneItem,
show_indicator: Option<Box<dyn Fn(&App) -> bool>>,
@ -136,7 +136,7 @@ impl SubView {
cx.new(|_| Self {
kind,
inner: view,
pane_focus_handle,
item_focus_handle,
show_indicator: show_indicator.unwrap_or(Box::new(|_| false)),
hovered: false,
})
@ -148,7 +148,7 @@ impl SubView {
}
impl Focusable for SubView {
fn focus_handle(&self, _: &App) -> FocusHandle {
self.pane_focus_handle.clone()
self.item_focus_handle.clone()
}
}
impl EventEmitter<()> for SubView {}
@ -199,7 +199,7 @@ impl Render for SubView {
.size_full()
// Add border unconditionally to prevent layout shifts on focus changes.
.border_1()
.when(self.pane_focus_handle.contains_focused(window, cx), |el| {
.when(self.item_focus_handle.contains_focused(window, cx), |el| {
el.border_color(cx.theme().colors().pane_focused_border)
})
.child(self.inner.clone())
@ -1202,7 +1202,9 @@ impl RunningState {
.as_ref()
.and_then(|pane| self.panes.find_pane_in_direction(pane, direction, cx))
{
window.focus(&pane.focus_handle(cx));
pane.update(cx, |pane, cx| {
pane.focus_active_item(window, cx);
})
} else {
self.workspace
.update(cx, |workspace, cx| {