Feat/better diff viewer
Merged
SO
4mo ago+978+978+012345678901234567890123456789-82-82-01234567890123456789
Objective
- Describe the objective or issue this PR addresses.
- If you're fixing a specific issue, use "Fixes #X" for each issue as described in the GitHub docs.
Solution
- Describe the solution used to achieve the objective above.
Testing
- Did you test these changes? If so, how?
- Are there any parts that need more testing?
- How can other people (reviewers) test your changes? Is there anything specific they need to know?
- If relevant, what platforms did you test these changes on, and are there any important ones you can't test?
Self-Review Checklist:
- I've reviewed my own diff for quality, security, and reliability
- Unsafe blocks (if any) have justifying comments
- The content adheres to Zed's UI standards (UX/UI and icon guidelines)
- Tests cover the new/changed behavior
- Performance impact has been considered and is acceptable
Showcase
This section is optional. If this PR does not include a visual change or does not add a new user-facing feature, you can delete this section.
- Help others understand the result of this PR by showcasing your awesome work!
- If this PR includes a visual change, consider adding a screenshot, GIF, or video
- A before/after comparison is very useful for changes to existing features!
While a showcase should aim to be brief and digestible, you can use a toggleable section to save space on longer showcases:
Click to view showcase
My super cool demos here
Release Notes:
- N/A or Added/Fixed/Improved ...
Summary by cubic
Adds an embeddable, view-only diff and a new commit diff preview, while keeping the default interactive diff unchanged. Hardens conflict handling, improves targeted git status refresh, fixes diff preview integration, and adds opt-in performance tracing.
-
New Features
ProjectDiffOptionswith toggles for hunk controls, review button, git panel addon, index mutations, and conflict view; newdeploy_at_with_options/deploy_at_project_path_with_optionswithProjectDiffOptions::embedded_view_only()for safe, view-only diffs.CommitDiffPreviewworkspace item for multi-file commit diffs with syntax highlighting and excerpted hunks; preview buffers are named by display path and thecommit_diff_previewmodule is exported for embedders.- Editor API:
SplittableEditor::set_delegate_stage_and_restoreto delegate stage/unstage/restore actions (used to disable index mutations in embedded mode). - Opt-in performance tracing for
CommitDiffPreviewviaCHERRYPICK_DIFF_PREVIEW_TRACE.
-
Bug Fixes
- Conflict UI no longer panics if the conflict addon is missing; subscriptions are only registered when conflict view is enabled.
- Improved git status updates with
GitStore::refresh_status_for_project_paths, batching path refreshes and setting a fallback active repo when needed. - Fixed Zed diff preview integration.
- Fixed embedded diff review: review button and toolbar are hidden in view-only mode; staging/restore commands are delegated and do not mutate the index; default
ProjectDiffbehavior remains interactive.
Summary by CodeRabbit
- New Features
- Added a commit diff preview workspace item to browse per-file changes in a temporary read-only view.
- Project diff views are now configurable via options (e.g., hunk controls, review button, conflict integration, and whether index edits are allowed).
- Status can now be refreshed for multiple project paths at once.
- Bug Fixes
- Improved conflict view handling to avoid crashes when conflict tracking isn’t available.
- Split editors now keep stage/restore behavior aligned and correctly delegate when enabled.