IssueRaiser

Commit partial changes / Line-by-line staging

### Discussed in https://github.com/zed-industries/zed/discussions/25949 <div type='discussions-op-text'> ### Core Requirements 1. **Update the git index directly** — When staging or unstaging a line, we need to update the actual git index, not just the Zed UI. This keeps behavior consistent with how hunk staging already works in Zed. 2. **Optimistic UI updates** — Staging and unstaging lines should be "optimistic," meaning the UI updates immediately when the user clicks. Hunk staging already works this way using "pending hunks" in the `buffer_diff` crate, which should be leveraged for line-by-line staging as well. ### Suggested Implementation Approach 1. **Teach diffs to render partially-staged hunks** — First, add the ability for existing diffs to "see" staged and unstaged lines within a diff hunk. If a user stages a single line using another tool and then views that hunk in Zed, we should render it correctly. This requires detecting when a hunk from the unstaged diff overlaps (but does not equal) a hunk from the uncommitted diff, and identifying which lines differ between those two hunks. 2. **Implement line staging/unstaging logic** — Once rendering works, implement the logic to compute the new text to write to the git index for a line staging or unstaging operation. 3. **Integrate with pending hunks** — Finally, ensure this works with pending hunks to support the optimistic UI behavior.</div>

Posted by franciskafyi on Dec 18, 2025, 8:28 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,000 issues0 comments

ux (Software)

Commit partial changes / Line-by-line staging

franciskafyiDec 18, 2025, 8:28 PM

### Discussed in https://github.com/zed-industries/zed/discussions/25949 <div type='discussions-op-text'> ### Core Requirements 1. **Update the git index directly** — When staging or unstaging a line, we need to update the actual git index, not just the Zed UI. This keeps behavior consistent with how hunk staging already works in Zed. 2. **Optimistic UI updates** — Staging and unstaging lines should be "optimistic," meaning the UI updates immediately when the user clicks. Hunk staging already works this way using "pending hunks" in the `buffer_diff` crate, which should be leveraged for line-by-line staging as well. ### Suggested Implementation Approach 1. **Teach diffs to render partially-staged hunks** — First, add the ability for existing diffs to "see" staged and unstaged lines within a diff hunk. If a user stages a single line using another tool and then views that hunk in Zed, we should render it correctly. This requires detecting when a hunk from the unstaged diff overlaps (but does not equal) a hunk from the uncommitted diff, and identifying which lines differ between those two hunks. 2. **Implement line staging/unstaging logic** — Once rendering works, implement the logic to compute the new text to write to the git index for a line staging or unstaging operation. 3. **Integrate with pending hunks** — Finally, ensure this works with pending hunks to support the optimistic UI behavior.</div>

Comments (0)

No comments yet. Start the discussion.

Comment on this issue