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
- This is the biggest problem with contracts, there's simply no way to actually say "please always execute this check".
- I don't disagree with you on this, I worked my whole life in corporate and haven't worked as a OSS maintainer before, though I will _and ...
- the new VSCode UI, looks cute, i don't like it.
- I've been working on my own private harness for the past 8 months, and I've been collecting ideas from such repos I've stumbled upon.
- The way AI is able to interact with outside resources is pretty impressive, but the quality of code it produces to me is still questionab...
- Add PR-style review comments in Git Diff UI that feed into the active agent thread
Raise real-world problems, find people facing the same issue, and discuss solutions.2,000 issues0 comments
ux (Software)
This is the biggest problem with contracts, there's simply no way to actually say "please always execute this check".
I don't disagree with you on this, I worked my whole life in corporate and haven't worked as a OSS maintainer before, though I will _and ...
the new VSCode UI, looks cute, i don't like it.
I've been working on my own private harness for the past 8 months, and I've been collecting ideas from such repos I've stumbled upon.
The way AI is able to interact with outside resources is pretty impressive, but the quality of code it produces to me is still questionab...
Add PR-style review comments in Git Diff UI that feed into the active agent thread
Thanks for indulging me so far, by the way, I really appreciate this discussion, it's very stimulating.
Migrate GDScript to the GDExtension mechanism and overhaul the implementation
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>
Comments (0)
No comments yet. Start the discussion.