# 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
Zed
Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Installation
On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).
Other platforms are not yet available:
- Web (tracking discussion)
Developing Zed
Contributing
See CONTRIBUTING.md for ways you can contribute to Zed.
Also... we're hiring! Check out our jobs page for open roles.
Licensing
Zed source code is licensed primarily under GPL-3.0-or-later, with Apache-2.0 components where marked.
License information for third party dependencies must be correctly provided for CI to pass.
We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:
- Is it showing a
no license specifiederror for a crate you've created? If so, addpublish = falseunder[package]in your crate's Cargo.toml. - Is the error
failed to satisfy license requirementsfor a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to theacceptedarray inscript/licenses/zed-licenses.toml. - Is
cargo-aboutunable to find the license for a dependency? If so, add a clarification field at the end ofscript/licenses/zed-licenses.toml, as specified in the cargo-about book.
Sponsorship
Zed is developed by Zed Industries, Inc., a for-profit company.
If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.