From 08c8e26ff901b4eabe97bf254f8d023ce96dace4 Mon Sep 17 00:00:00 2001 From: rabsef-bicrym <52549148+rabsef-bicrym@users.noreply.github.com> Date: Thu, 18 Dec 2025 04:11:14 -0800 Subject: [PATCH] terminal: Respect RevealStrategy::NoFocus and Never focus settings (#45180) Closes #45179 ## Summary Fixes the focus behavior when creating terminals with `RevealStrategy::NoFocus` or `RevealStrategy::Never`. Previously, terminals would still receive focus if the terminal pane already had focus, contradicting the documented behavior. ## Changes - **`add_terminal_task()`**: Changed focus logic to only focus when `RevealStrategy::Always` - **`add_terminal_shell()`**: Same fix The fix changes: ```rust // Before let focus = pane.has_focus(window, cx) || matches!(reveal_strategy, RevealStrategy::Always); // After let focus = matches!(reveal_strategy, RevealStrategy::Always); ``` ## Impact This affects: - Vim users running `:!command` (uses `NoFocus`) - Debugger terminal spawning (uses `NoFocus`) - Any programmatic terminal creation requesting background behavior Release Notes: - Fixed terminal focus behavior to respect `RevealStrategy::NoFocus` and `RevealStrategy::Never` settings when the terminal pane already has focus. --- crates/terminal_view/src/terminal_panel.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index 85c6b81f40..a00e544f97 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -790,8 +790,7 @@ impl TerminalPanel { } pane.update(cx, |pane, cx| { - let focus = pane.has_focus(window, cx) - || matches!(reveal_strategy, RevealStrategy::Always); + let focus = matches!(reveal_strategy, RevealStrategy::Always); pane.add_item(terminal_view, true, focus, None, window, cx); }); @@ -853,8 +852,7 @@ impl TerminalPanel { } pane.update(cx, |pane, cx| { - let focus = pane.has_focus(window, cx) - || matches!(reveal_strategy, RevealStrategy::Always); + let focus = matches!(reveal_strategy, RevealStrategy::Always); pane.add_item(terminal_view, true, focus, None, window, cx); });