From 7327ef662b0012c29f11db283ca422f474752a72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20von=20G=C3=B6wels?= Date: Wed, 3 Sep 2025 16:23:46 +0200 Subject: [PATCH] terminal_view: Fix focusing of center-pane terminals (#37359) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With `reveal_stragegy=always` + `reveal_target=center`, `TerminalPanel::spawn_task` activates & focuses the pane of the task. This works fine in the terminal pane but doesn't for `reveal_target=center`. Please note: I'm not verified familiar with the architecture and internal APIs of zed. If there's a better way or if this fix is a bad idea, I'm fine with adapting this 😃 Closes #35908 Release Notes: - Fixed task focus when re-spawning a task with `reveal_target=center` --------- Co-authored-by: Marshall Bowers --- crates/terminal_view/src/terminal_panel.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index 848737aeb24ef52a6819e57882ab022edef94e25..2ba7f617bf407299b2b0e670f66432ce053718be 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -41,7 +41,7 @@ use workspace::{ ui::IconName, }; -use anyhow::{Context as _, Result, anyhow}; +use anyhow::{Result, anyhow}; use zed_actions::assistant::InlineAssist; const TERMINAL_PANEL_KEY: &str = "TerminalPanel"; @@ -905,11 +905,16 @@ impl TerminalPanel { RevealStrategy::Always => match reveal_target { RevealTarget::Center => { task_workspace.update_in(cx, |workspace, window, cx| { - workspace - .active_item(cx) - .context("retrieving active terminal item in the workspace")? - .item_focus_handle(cx) - .focus(window); + let did_activate = workspace.activate_item( + &terminal_to_replace, + true, + true, + window, + cx, + ); + + anyhow::ensure!(did_activate, "Failed to retrieve terminal pane"); + anyhow::Ok(()) })??; }