git_ui: Open focused single-file diff from commit diff multibuffer - #62074
Closed
gaojunran wants to merge 2 commits into
Closed
git_ui: Open focused single-file diff from commit diff multibuffer#62074gaojunran wants to merge 2 commits into
gaojunran wants to merge 2 commits into
Conversation
When clicking 'Open File' or the context menu 'Open File Diff' inside a CommitView's diff multibuffer, open a SoloDiffView (focused single-file diff) instead of a plain read-only file view. Extends SoloDiffView with a DiffSource enum (Uncommitted | Commit) to support commit diffs. Commit diff mode uses RestoreOnlyDiffHunkDelegate, hides staging/commit toolbar buttons, and shows the commit short SHA in the tab title.
5 tasks
Member
|
We currently enforce a 3 PR limit per contributor in our Not saying this cannot be opened again, yet please consider this only if you are within limits again. Thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When clicking the Open File button or the context menu Open File Diff inside a CommitView's diff multibuffer, the editor currently opens a plain read-only file view with no diff styling. This is confusing — users expect to see a diff, not a bare file.
This PR extends
SoloDiffViewto support commit diffs, so both entry points open a focused single-file diff view instead.SoloDiffViewfor Git Panel working-tree diffsShowcase
This PR (has diff style):
2026-08-02.19.01.24.mov
Upstream main (no diff style):
2026-08-02.19.07.44.mov
Changes
solo_diff_view.rsDiffSourceenum (Uncommitted|Commit { sha }) to distinguish working-tree diffs from commit diffsopen_or_focus_commit()— loads the commit diff, filters to a single file, reusesbuild_buffer/build_buffer_difffromcommit_view.rs, and creates aSoloDiffViewwithDiffSource::Commitnew()accepts adiff_sourceparameter; commit diffs useRestoreOnlyDiffHunkDelegate(matching CommitView behavior)matches()/matches_commit()— deduplication correctly distinguishes uncommitted and commit diff viewsbutton_states()early-returns with all staging/restore buttons disabled for commit diffsSoloDiffGitToolbar— commit diffs only show Prev/Next Hunk + diff stat; staging/commit buttons hidden via.when(!is_commit_diff, ...)SoloDiffStyleToolbar— commit diffs skip the status iconbreadcrumbs— commit diffs skipstatus_for_path(no misleading working-tree status)"{short_sha} — {file_name}"; tooltip shows full SHA + pathcommit_view.rsGitBlob,build_buffer,build_buffer_diffchanged topub(crate)for reusedelegate_open_excerpts(true)— intercepts the "Open File" button click, emitsOpenExcerptsRequestedhandle_editor_event— onOpenExcerptsRequested, extracts the buffer's file path and opensSoloDiffView::open_or_focus_commitclone_on_split— also setsdelegate_open_excerpts(true)and subscribes to the event (covers split mode RHS)open_or_focus_commitinstead ofopen_path_previewOpenFileAtHeadaction handler also callsopen_or_focus_commitopen_file_diffhelper to eliminate duplicated call patternopen_file_at_head(no longer called)Self-Review Checklist:
Release Notes: