feat: Allow for patch stage/unstage in Git diff viewer#585
feat: Allow for patch stage/unstage in Git diff viewer#585atreat wants to merge 16 commits intoDimillian:mainfrom
Conversation
…ining actionable hunks
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dfee6d8a7e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let (diff_args, reverse_apply): (&[&str], bool) = match source { | ||
| "unstaged" => (&["diff", "--no-color", "-U0", "--"], false), | ||
| "staged" => (&["diff", "--cached", "--no-color", "-U0", "--"], true), | ||
| _ => unreachable!(), |
There was a problem hiding this comment.
Use ignore-whitespace mode when resolving display hunk IDs
When git_diff_ignore_whitespace_changes is enabled, get_git_diffs_inner computes displayHunkId values from git diff -w -U0 hunks, but this branch rebuilds the source patch without -w. In hunks that mix whitespace-only edits with real edits, the hunk header tuple (old_start/old_count/new_start/new_count) can differ, so build_display_hunk_patch cannot find the ID and returns “Display hunk no longer matches…”, breaking hunk stage/unstage in that mode.
Useful? React with 👍 / 👎.
Changes
Idea is to keep action buttons near the center of the scrollable region so see can skim through changes and quickly stage/unstage hunks.
Screenshots:
stage hunk:

unstage hunk:

unstage deletion only:
