Fix expand/collapse all button for splittable editor#50859
Merged
Conversation
We were downcasting just to `Editor`, without taking into account that we might be handling a `SplittableEditor`. Might want to refactor this in a way that doesn't involve downcasting. Co-authored-by: Tom Houlé <tom@tomhoule.com>
Same thing as previous commit, we were downcasting to `Editor` only, while we also need to handle `SplittableEditor`. Co-authored-by: Tom Houlé <tom@tomhoule.com>
Refactor the approach of downcasting the `BufferSearchBar::active_searchable_item` to either an `Editor` or `SplittableEditor` in order to fold or unfold all excerpts, to a more explicit `FoldableItem` trait. This way we avoid downcasting, we'll still need to update tests in a future commit. Co-authored-by: Tom Houlé <tom@tomhoule.com>
- Remove default `impl` on `CollapsibleItem::has_any_folded` to force implementors to provide it explicitly - Change `has_any_collapsed` to take `&App` instead of `&Context<Self>`, use `read`() instead of `update`() in the blanket `impl` - Move `CollapsibleItem`/`CollapsibleItemHandle` from `searchable.rs` to `collapsible.rs` - Add missing `as_collapsible` implementations for `ProjectDiagnosticsEditor`, `AgentDiffPane`, `CommitView`, `MultiDiffView` and `TextDiffView` - Guard `needs_expand_collapse_option` on `active_collapsible_item` presence in order to prevent the expand/collapse all button from being shown if the buffer search bar does not have a collapsible item handle - Inline `rhs_editor` delegation in `SplittableEditor`'s `CollapsibleItem` impl As a note, tests still might need to be updated eventually to better test this `CollapsibleItemHandle` path. Co-authored-by: Tom Houlé <tom@tomhoule.com>
Member
Author
|
A quick screen recording of the before and after of the button's behavior in the Git Diff view, for comparison ▼ Before CleanShot.2026-03-05.at.20.41.06.mp4After CleanShot.2026-03-05.at.20.40.23.mp4 |
Bundle the searchable and collapsible item handles into an `ActiveItem` struct so they are always set and cleared atomically. Add `searchable()`, `collapsible()`, and `collapsible_mut()` accessor methods on `BufferSearchBar` to reduce direct field access. Replace all `active_searchable_item` and `active_collapsible_item` field references with the new struct and accessors.
c43b17f to
11fd436
Compare
Revert changes introduced so far in order to explore updating `SplittableEditor`'s implementation of the `Item` trait, to make it able to act as an `Editor`.
4eb379e to
9f50c8f
Compare
Update the `workspace::item::Item` trait implementation for `editor::split::SplittableEditor` to ensure that it can act as an `editor::Editor`. This fixes a bug where the all files expand/collapse button was not working on the project diff view. Since the `ProjectDiff::as_searchable` implementation returns an handle to the `SplittableEditor`, whenever the `BufferSearchBar` tried to downcast the handle to an `Editor`, this would silently fail.
9f50c8f to
e096443
Compare
Member
Author
|
/cherry-pick preview |
github-actions bot
pushed a commit
that referenced
this pull request
Mar 9, 2026
The "Expand All Files"/"Collapse All Files" button in `BufferSearchBar` was broken for `SplittableEditor`, which is used in the project diff view. It was happening because `ProjectDiff::as_searchable` returns an handle to the `SplittableEditor`, which the search bar implementation then tries to downcast to an `Editor`, which the `SplittableEditor` did not support, so both the expand/collapse all buttons, as well as the collapse state were broken. Unfortunately this was accidentally introduced in #48773 , so this Pull Request updates the `Item` implementation for `SplittableEditor` in order for it to be able to act as an `Editor`. Release Notes: - Fix the "Expand All Files"/"Collapse All Files" button in the project diff view --------- Co-authored-by: Tom Houlé <tom@tomhoule.com>
zed-zippy bot
added a commit
that referenced
this pull request
Mar 9, 2026
…-pick to preview) (#51124) Cherry-pick of #50859 to preview ---- The "Expand All Files"/"Collapse All Files" button in `BufferSearchBar` was broken for `SplittableEditor`, which is used in the project diff view. It was happening because `ProjectDiff::as_searchable` returns an handle to the `SplittableEditor`, which the search bar implementation then tries to downcast to an `Editor`, which the `SplittableEditor` did not support, so both the expand/collapse all buttons, as well as the collapse state were broken. Unfortunately this was accidentally introduced in #48773 , so this Pull Request updates the `Item` implementation for `SplittableEditor` in order for it to be able to act as an `Editor`. Release Notes: - Fix the "Expand All Files"/"Collapse All Files" button in the project diff view --------- Co-authored-by: Tom Houlé <tom@tomhoule.com> Co-authored-by: Dino <dinojoaocosta@gmail.com> Co-authored-by: Tom Houlé <tom@tomhoule.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The "Expand All Files"/"Collapse All Files" button in
BufferSearchBarwas broken forSplittableEditor, which is used in the project diff view. It was happening becauseProjectDiff::as_searchablereturns an handle to theSplittableEditor, which the search bar implementation then tries to downcast to anEditor, which theSplittableEditordid not support, so both the expand/collapse all buttons, as well as the collapse state were broken.Unfortunately this was accidentally introduced in #48773 , so this Pull Request updates the
Itemimplementation forSplittableEditorin order for it to be able to act as anEditor.Before you mark this PR as ready for review, make sure that you have:
Release Notes: