Skip to content

editor: Remove folded buffer ID on all excerpts removed#50525

Merged
dinocosta merged 2 commits intomainfrom
50521-clear-folded-buffers
Mar 2, 2026
Merged

editor: Remove folded buffer ID on all excerpts removed#50525
dinocosta merged 2 commits intomainfrom
50521-clear-folded-buffers

Conversation

@dinocosta
Copy link
Copy Markdown
Member

@dinocosta dinocosta commented Mar 2, 2026

Fix a bug in the editor's handling of the multi_buffer::Event::ExcerptsRemoved event, where the display map's folded_buffers set was not updated according to the list of removed buffer ids.

Since the ProjectSearchView now relies on the Editor.has_any_buffer_folded method in order to decide the state of the expand/collapse all excerpts button (updated on #48773) this could lead to a bug where, after an initial project search, all excerpts would be collapsed, and performing a new search would leave the button in a wrong state, as all excerpts from the new search result would be expanded, but the button would still consider that there were folded excerpts for the buffers.

Closes #50521

Before you mark this PR as ready for review, make sure that you have:

  • Added a solid test coverage and/or screenshots from doing manual testing
  • Done a self-review taking into account security and performance aspects
  • Aligned any UI changes with the UI checklist

Release Notes:

  • Fixed bug in project search where collapsing a single buffer then performing a new search in the same view, would break the expand/collapse all button behavior

Fix a bug in the editor's handling of the
`multi_buffer::Event::ExcerptsRemoved` event, where the display map's
`folded_buffers` set was not updated according to the list of removed
buffer ids.

Since the `ProjectSearchView` now relies on the
`Editor.has_any_buffer_folded` method in order to decide the state of
the expand/collapse all excerpts button, this could lead to a bug where,
after an initial project search, all excerpts would be collapsed, and
performing a new search would leave the button in a wrong state, as all
excerpts from the new search result would be expanded, but the button
would still consider that there were folded excerpts for the buffers.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 2, 2026
@dinocosta dinocosta self-assigned this Mar 2, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Mar 2, 2026
@maxdeviant maxdeviant changed the title editor: Remove folded buffer id on all excerpts removed editor: Remove folded buffer ID on all excerpts removed Mar 2, 2026
@dinocosta dinocosta enabled auto-merge (squash) March 2, 2026 22:03
@dinocosta dinocosta merged commit 1f11592 into main Mar 2, 2026
29 checks passed
@dinocosta dinocosta deleted the 50521-clear-folded-buffers branch March 2, 2026 22:13
Veykril pushed a commit that referenced this pull request Mar 4, 2026
Refactor the changes introduced in
#50525, in order to remove the
`DisplayMap.clear_folded_buffer` method and update the editor's handling
of `multi_buffer::Event::ExcerptsRemoved` to actually call
`DisplayMap.unfold_buffers`, which correctly updates the `BlockMap`
using its `BlockMapWriter`, ensuring that the block map is synced.

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
- [X] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- N/A
tahayvr pushed a commit to tahayvr/zed that referenced this pull request Mar 4, 2026
…es#50525)

Fix a bug in the editor's handling of the
`multi_buffer::Event::ExcerptsRemoved` event, where the display map's
`folded_buffers` set was not updated according to the list of removed
buffer ids.

Since the `ProjectSearchView` now relies on the
`Editor.has_any_buffer_folded` method in order to decide the state of
the expand/collapse all excerpts button this could lead to a
bug where, after an initial project search, all excerpts would be
collapsed, and performing a new search would leave the button in a wrong
state, as all excerpts from the new search result would be expanded, but
the button would still consider that there were folded excerpts for the
buffers.

Closes zed-industries#50521

Release Notes:

- Fixed bug in project search where collapsing a single buffer then
performing a new search in the same view, would break the
expand/collapse all button behavior
wzulfikar pushed a commit to wzulfikar/zed that referenced this pull request Mar 4, 2026
…es#50525)

Fix a bug in the editor's handling of the
`multi_buffer::Event::ExcerptsRemoved` event, where the display map's
`folded_buffers` set was not updated according to the list of removed
buffer ids.

Since the `ProjectSearchView` now relies on the
`Editor.has_any_buffer_folded` method in order to decide the state of
the expand/collapse all excerpts button this could lead to a
bug where, after an initial project search, all excerpts would be
collapsed, and performing a new search would leave the button in a wrong
state, as all excerpts from the new search result would be expanded, but
the button would still consider that there were folded excerpts for the
buffers.

Closes zed-industries#50521

Release Notes:

- Fixed bug in project search where collapsing a single buffer then
performing a new search in the same view, would break the
expand/collapse all button behavior
wzulfikar pushed a commit to wzulfikar/zed that referenced this pull request Mar 4, 2026
Refactor the changes introduced in
zed-industries#50525, in order to remove the
`DisplayMap.clear_folded_buffer` method and update the editor's handling
of `multi_buffer::Event::ExcerptsRemoved` to actually call
`DisplayMap.unfold_buffers`, which correctly updates the `BlockMap`
using its `BlockMapWriter`, ensuring that the block map is synced.

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
- [X] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- N/A
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 staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project Search's expand/collapse button broken when searching after folding

2 participants