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