zed/crates/buffer_diff
Lukas Wirth ebd80d7995
buffer_diff: Fix panic when staging hunks with stale buffer snapshot (#51641)
When the buffer is edited after the diff is computed but before staging,
anchor positions shift while diff_base_byte_range values don't. If the
primary (HEAD) hunk extends past the unstaged (index) hunk, an edit in
the extension region causes the overshoot calculation to produce an
index_end that exceeds index_text.len(), panicking in
rope::Cursor::suffix.

Fix by clamping index_end to index_text.len(). This is safe because the
computed index text is an optimistic approximation — the real staging
happens at the filesystem level via git add/git reset.

Closes ZED-5R2


Release Notes:

- Fixed a source of panics when staging diff hunks
2026-03-16 09:49:02 +01:00
..
src buffer_diff: Fix panic when staging hunks with stale buffer snapshot (#51641) 2026-03-16 09:49:02 +01:00
Cargo.toml Remove unreferenced dev dependencies (#51093) 2026-03-09 13:22:12 +01:00
LICENSE-GPL Add staged status information to diff hunks (#24475) 2025-02-10 21:43:25 -05:00