Commit diff multibuffer: "Open File" button opens plain read-only file instead of diff view #62068
gaojunran
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
When viewing a commit diff (e.g., from Git Panel > History > click a commit), the diff is displayed as a multibuffer showing all changed files. Each file section has a file header with an "Open File" button on the right side, and right-clicking the header shows an "Open File in Project" context menu entry.
Clicking either of these opens the file at HEAD as a plain, read-only editor view — no diff highlighting, no hunk staging controls, no way to see what changed in that commit for that file. This is confusing because the user is in a diff context and expects to see diff styling.
Expected behavior
Like PR #56152 (
git_ui: Open file diffs from git panel), which made the Git Panel double-click open aSoloDiffViewwith full diff styling, the "Open File" button and "Open File in Project" context menu in the commit diff multibuffer should also open a diff view for that specific file — showing the changes introduced by that commit, with diff highlighting and hunk-level controls.Current code path
"Open File" button (
crates/editor/src/element/header.rs~line 928): callseditor.open_excerpts_common()→open_buffers_in_workspace()→workspace.open_project_item::<Editor>(). This opens a plainEditor. For non-project files (git blobs at HEAD),set_read_only(true)is called (~line 10212). No diff styling."Open File in Project" context menu (
crates/git_ui/src/commit_view.rs~line 144,CommitDiffAddon::extend_buffer_header_context_menu): callsopen_file_at_head()→workspace.open_path_preview(). Also opens a plain file view at HEAD.For comparison, the Git Panel (working tree changes) already has
git::OpenFileDiffaction →SoloDiffView::open_or_focus()(crates/git_ui/src/git_ui.rs~line 335), which opens a proper diff view. But this is only wired up for files with working-tree status, not for commit diff buffers.Suggested approach
Extend
SoloDiffView(or create a similar view) to support opening a single-file diff for a specific commit, and wire it up as the action behind the "Open File" button and context menu in the commit diff multibuffer.All reactions