mirror of
https://github.com/zed-industries/zed.git
synced 2026-08-21 23:14:27 +00:00
# Objective Ensure that the "Discard Tracked Changes" option shown in the context menu that can be opened in the Git Panel's "Changes" tab is only displayed when it can actually be used. Currently, it is also shown when the "Unstaged" section has tracked files, even though clicking will not actually do anything. Besides fixing that, the changes in this Pull Request also update how the "Discard Tracked Changes" action works when picked from a subfolder, with only changes in that subfolder being discarded. Closes #62535 ## Solution - Update `git_ui::git_panel::git_panel_context_menu` to now accept a `has_staged_tracked_changes` boolean, in order to be able to differentiate between the panel having tracked changes, be it unstaged or staged, and specifically staged tracked changes, as we only want the "Discard Tracked Changes" to be enabled and affect staged changes. - Add `git_ui::git_panel::GitPanel::directory_context_descendants` in order to be able to obtain the list of entries under the directory where the context menu was deployed, if any. - Update `git_ui::git_panel::GitPanel::restored_tracked_files` to leverage the new `directory_context_descendants` method, ensuring that only the entries under the context menu's directory are restored, instead of all staged tracked files ## Testing Tested both manually, as shown in the "Showcase" section, as well as introduced a new test for these changes – `git_ui::git_panel::tests::test_directory_discard_tracked_changes`. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [ ] 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 ## Showcase <details> <summary>Before</summary> https://github.com/user-attachments/assets/24bbb23c-78fb-4fe3-82da-d8bcaec0d79c </details> <details> <summary>After</summary> https://github.com/user-attachments/assets/70db9189-9122-4ee4-b03f-648935c4f0a4 </details> --- Release Notes: - Fixed the "Discard Tracked Changes" option being enabled for files in the "Unstaged" section in the Git Panel - Updated the "Discard Tracked Changes" option to only affects files in the directory where the context menu was deployed |
||
|---|---|---|
| .. | ||
| src | ||
| Cargo.toml | ||
| LICENSE-GPL | ||