From cc56ed7a880c3bf4b4f5342b1e5b7ab8ebd99359 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 17 Dec 2024 14:19:13 +0200 Subject: [PATCH] Focus terminal when creating one after activating the terminal panel (#22133) Follow-up of https://github.com/zed-industries/zed/pull/22082 Release Notes: - N/A --- crates/terminal_view/src/terminal_panel.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index a3cff1dbd4..725a330235 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -724,8 +724,6 @@ impl TerminalPanel { cx: &mut ViewContext, ) -> Task>> { let workspace = self.workspace.clone(); - self.pending_terminals_to_add += 1; - cx.spawn(|terminal_panel, mut cx| async move { if workspace.update(&mut cx, |workspace, cx| { !is_enabled_in_workspace(workspace, cx) @@ -753,10 +751,6 @@ impl TerminalPanel { cx, ) })); - pane.update(cx, |pane, cx| { - let focus = pane.has_focus(cx); - pane.add_item(terminal_view, true, focus, None, cx); - }); match reveal_strategy { RevealStrategy::Always => { @@ -767,6 +761,13 @@ impl TerminalPanel { } RevealStrategy::Never => {} } + + pane.update(cx, |pane, cx| { + let focus = + pane.has_focus(cx) || matches!(reveal_strategy, RevealStrategy::Always); + pane.add_item(terminal_view, true, focus, None, cx); + }); + Ok(terminal) })?; terminal_panel.update(&mut cx, |this, cx| {