search: Fix deleted files persisting in project search results#50551
Conversation
Add test_deleted_file_removed_from_search_results covering proactive removal and re-search filtering. Scope the excerpts borrow in a block to avoid a dropping_references warning.
|
does this fix #28398 (I was hoping to take that one) |
This partially addresses #28398, specifically the part about deleted files persisting in search results. The |
|
Thank you for your PR!
I'm not sure about that behavior, but let's roll with it. Specifically, I don't think we have a precedent for removing entries from an existing multi-buffer. |
First of all, thanks for your time invested @osiewicz! I adjusted the rustfmt errors. Can you run the tests again? |
|
Let's merge this after today's releases to have 2 weeks of baking time on Nightly/Preview. |
Yeah, sounds good for me! |
…ndustries#50551) Closes zed-industries#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
…ndustries#50551) Closes zed-industries#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
…ndustries#50551) Closes zed-industries#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
|
This was a big issue for me, thanks so much @Dnreikronos! |
You're welcome, mate! |
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 aproject_entry_id()(which happens whenDiskState::Deleted) as "unnamed buffers" and fed themdirectly into the search pipeline. The multibuffer's strong
Entity<Buffer>reference kept the buffer alive.Fix:
into_handle()andall_loaded_buffers()FileHandleChangedevents on the search multibuffer to proactively remove deleted files from existing resultsBefore you mark this PR as ready for review, make sure that you have:
Video:
https://drive.google.com/file/d/1pEz6JywFcZlz8aiXbLOxIdj84SQWLIiF/view?usp=sharing
Release Notes: