# git_panel: Scope folder expansion state to sections \(\#60396\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 62477092a20938d07de278555b1e99fd07b79b4f

Requested commit: 62477092a20938d07de278555b1e99fd07b79b4f

Commit: 62477092a20938d07de278555b1e99fd07b79b4f

Tree: 608d22e350e1df14d449e951f62ba8256602bf7d

Author: Sathwik Chirivelli

Committer: GitHub

## Message

```
git_panel: Scope folder expansion state to sections (#60396)

# Objective

Prevent collapsing a folder in one Git panel section from also
collapsing the same folder path in other sections.

## Solution

Key directory expansion state by `TreeKey`, which includes both the
section and repository path, instead of by `RepoPath` alone. This also
keeps persisted tree state, stale-state cleanup, and selected-file
reveal behavior section-aware.

## Testing

- Added `test_tree_view_directory_expansion_is_scoped_to_section` to
cover the same folder path under Tracked and Untracked independently.
- `cargo fmt -p git_ui -- --check`
- `git diff --check`
- Attempted `cargo test -p git_ui
test_tree_view_directory_expansion_is_scoped_to_section --lib`, but
dependency compilation could not complete because the local disk ran out
of space. Reviewers can run that command to execute the focused
regression test.

## 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)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Suggested .rules additions

- In the Git panel tree view, key per-row UI state by `TreeKey` rather
than `RepoPath`, because the same directory can appear in multiple
sections.

---

Release Notes:

- Fixed collapsing a folder in one Git panel section also collapsing it
in other sections.
```

## Parents

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

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