# Objective
When reviewing changes in the Git Panel, the only ways to open a file
were through a diff view ("Open Diff" or "Open Diff (File)"). There was
no way to open the file directly in the editor to inspect or edit its
current contents without entering a diff.
This PR adds a **View File** action to the Git Panel changes list
context menu.
## Solution
- Add a `git::ViewFile` action in `crates/git/src/git.rs`, alongside
other per-file git actions like `FileHistory`.
- Wire it into the Git Panel file context menu, between the diff actions
and "View File History".
- Implement `GitPanel::view_file` to resolve the selected entry's repo
path to a project path and open it via `workspace.open_path_preview`,
matching the pattern used in `commit_view::open_file_at_head`.
- Document the new action in `docs/src/git.md`.
### Related issues
- https://github.com/zed-industries/zed/issues/58250
## Testing
- Added three GPUI tests in `git_panel.rs`:
- `test_view_file_tracked` — modified tracked file
- `test_view_file_untracked` — untracked file
- `test_view_file_tree_view` — nested file in tree view
- Ran `cargo test -p git_ui test_view_file` — all three pass.
- Ran `./script/clippy -p git_ui` — clean.
**Manual testing for reviewers:**
1. Open a project with changed files and open the Git Panel.
2. Right-click a changed file and select **View File**.
3. Confirm the file opens in the editor (not a diff view).
4. Repeat for an untracked file and with tree view enabled.
5. Confirm **Open Diff** and **Open Diff (File)** still work.
Tested on macOS only. Linux and Windows should behave the same since
this is a context menu action with no platform-specific code, but I
haven't verified on those platforms.
## 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
## Showcase
<details>
<summary>Click to view showcase</summary>
Video recoding of the Git Panel context menu showing the new **View
File** item:
https://github.com/user-attachments/assets/c878fd4d-9acb-4c05-bd91-b452da0a6b90
</details>
---
Release Notes:
- Added "View File" to the Git Panel context menu to open a changed file
in the editor without a diff view.
---------
Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>3 files changedLine totals unavailable