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

@ -62,6 +62,7 @@ impl Console {
editor.set_soft_wrap_mode(language::language_settings::SoftWrap::EditorWidth, cx);
editor
});
let focus_handle = cx.focus_handle();
let this = cx.weak_entity();
let query_bar = cx.new(|cx| {
@ -76,10 +77,14 @@ impl Console {
editor
});
let focus_handle = query_bar.focus_handle(cx);
let _subscriptions =
vec![cx.subscribe(&stack_frame_list, Self::handle_stack_frame_list_events)];
let _subscriptions = vec![
cx.subscribe(&stack_frame_list, Self::handle_stack_frame_list_events),
cx.on_focus_in(&focus_handle, window, |console, window, cx| {
if console.is_running(cx) {
console.query_bar.focus_handle(cx).focus(window);
}
}),
];
Self {
session,
@ -99,7 +104,7 @@ impl Console {
&self.console
}
fn is_local(&self, cx: &Context<Self>) -> bool {
fn is_running(&self, cx: &Context<Self>) -> bool {
self.session.read(cx).is_local()
}
@ -221,7 +226,7 @@ impl Render for Console {
.on_action(cx.listener(Self::evaluate))
.size_full()
.child(self.render_console(cx))
.when(self.is_local(cx), |this| {
.when(self.is_running(cx), |this| {
this.child(Divider::horizontal())
.child(self.render_query_bar(cx))
})