# search: Fix deleted files persisting in project search results \(\#50551\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 0238d2d180c62ae3f53ed5fd9efb6d2569555706

Requested commit: 0238d2d180c62ae3f53ed5fd9efb6d2569555706

Commit: 0238d2d180c62ae3f53ed5fd9efb6d2569555706

Tree: 80769c11cdfa2539d300810db5720f51f3fb82ce

Author: João Soares

Committer: GitHub

## Message

```
search: Fix deleted files persisting in project search results (#50551)

Closes #50524

When a file is deleted while project search results are displayed, the
deleted file's buffer was kept alive by the search multibuffer and would
reappear on re-search.

**Root cause:** `Search::into_handle()` treated buffers without a
`project_entry_id()` (which happens when `DiskState::Deleted`) as
"unnamed buffers" and fed them
directly into the search pipeline. The multibuffer's strong
`Entity<Buffer>` reference kept the buffer alive.

**Fix:**
- Filter deleted-file buffers from search candidates in `into_handle()`
and `all_loaded_buffers()`
- Subscribe to `FileHandleChanged` events on the search multibuffer to
proactively remove deleted files from existing results

Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [ ] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

### Video:

https://drive.google.com/file/d/1pEz6JywFcZlz8aiXbLOxIdj84SQWLIiF/view?usp=sharing

Release Notes:

- Fixed deleted files persisting in project search results
```

## Parents

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

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