# Fix focus handling in ProjectSearchBar\. \(\#61093\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/625b29d243c4e163d39c7be5276ebaca0604e3a2)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 625b29d243c4e163d39c7be5276ebaca0604e3a2

Requested commit: 625b29d243c4e163d39c7be5276ebaca0604e3a2

Commit: 625b29d243c4e163d39c7be5276ebaca0604e3a2

Tree: 71c8f45677d46129472578412fa1cc343df50941

Author: ian

Committer: GitHub

## Message

```
Fix focus handling in ProjectSearchBar. (#61093)

# Objective

Fix #61023

When project search is already open and focused, pressing the project
search shortcut again (`cmd-shift-f` / `ctrl-shift-f`) only re-focused
the query editor and did not select the existing query text. That made
it hard to quickly retype a search term—especially after a no-results
search, when focus stays in the search bar.

This aligns project search behavior with buffer search, where
`FocusSearch` focuses and selects the query.

## Solution

In `ProjectSearchBar::focus_search`, call `focus_query_editor` instead
of only focusing the query editor. `focus_query_editor` already focuses
the field and selects all text (same path used by `DeploySearch`).

## Testing

- [ ] Manual: open project search → type a non-matching query → Enter →
press project search shortcut again → query text should be selected so
typing replaces it
- [ ] Manual: same flow after a search that returns matches
- [ ] Manual: compare with buffer search (`cmd-f` / `ctrl-f`) to confirm
consistent “refocus selects query” behavior
- Platforms: tested / to be tested on macOS; Linux/Windows should behave
the same via the shared `FocusSearch` action

No automated test added yet; a `gpui::test` that deploys project search,
dispatches `FocusSearch`, and asserts the query editor selection would
be a good follow-up.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- N/A
```

## Parents

- [93b846b2a65715977841dd1fffcb3dce40588c66](https://git.cafe/gitcafe/zed/commit/93b846b2a65715977841dd1fffcb3dce40588c66?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/625b29d243c4e163d39c7be5276ebaca0604e3a2?format=markdown)
