Skip to content

terminal: Respect RevealStrategy::NoFocus and Never focus settings#45180

Merged
Veykril merged 1 commit intozed-industries:mainfrom
rabsef-bicrym:fix/reveal-strategy-focus-behavior
Dec 18, 2025
Merged

terminal: Respect RevealStrategy::NoFocus and Never focus settings#45180
Veykril merged 1 commit intozed-industries:mainfrom
rabsef-bicrym:fix/reveal-strategy-focus-behavior

Conversation

@rabsef-bicrym
Copy link
Contributor

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:

// 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.

The focus logic in add_terminal_task() and add_terminal_shell() was checking
if the pane already had focus, which caused terminals to steal focus even
when RevealStrategy::NoFocus or Never was specified.

This contradicts the documented behavior:
- NoFocus: "don't focus it"
- Never: "Do not alter focus"

The fix changes the focus calculation from:
  `pane.has_focus(window, cx) || matches!(reveal_strategy, RevealStrategy::Always)`
to:
  `matches!(reveal_strategy, RevealStrategy::Always)`

This ensures focus is only given when explicitly requested via Always strategy.

Fixes zed-industries#45179
@cla-bot
Copy link

cla-bot bot commented Dec 18, 2025

We require contributors to sign our Contributor License Agreement, and we don't have @rabsef-bicrym on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@rabsef-bicrym
Copy link
Contributor Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 18, 2025
@cla-bot
Copy link

cla-bot bot commented Dec 18, 2025

The cla-bot has been summoned, and re-checked this pull request!

@github-project-automation github-project-automation bot moved this to Community Champion PRs in Quality Week – December 2025 Dec 18, 2025
@miguelraz miguelraz moved this from Community Champion PRs to Community PRs in Quality Week – December 2025 Dec 18, 2025
@maxdeviant maxdeviant changed the title fix(terminal): Respect RevealStrategy::NoFocus and Never focus settings terminal: Respect RevealStrategy::NoFocus and Never focus settings Dec 18, 2025
@Veykril Veykril self-assigned this Dec 18, 2025
Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Veykril Veykril enabled auto-merge (squash) December 18, 2025 11:55
@Veykril Veykril merged commit 5488a19 into zed-industries:main Dec 18, 2025
26 checks passed
@github-project-automation github-project-automation bot moved this from Community PRs to Done in Quality Week – December 2025 Dec 18, 2025
@rabsef-bicrym rabsef-bicrym deleted the fix/reveal-strategy-focus-behavior branch December 18, 2025 16:48
rtfeldman pushed a commit that referenced this pull request Jan 5, 2026
…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.
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…ed-industries#45180)

Closes zed-industries#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.
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…ed-industries#45180)

Closes zed-industries#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

Development

Successfully merging this pull request may close these issues.

RevealStrategy::NoFocus and RevealStrategy::Never do not respect focus settings when terminal pane has focus

2 participants