Fix innermost brackets panic (#32120)

Release Notes:

- Fixed a few rare panics that could happen when a multibuffer excerpt
started with expanded deleted content.
This commit is contained in:
Conrad Irwin 2025-06-05 14:24:56 -06:00 committed by GitHub
parent 7aa70a4858
commit 4b297a9967
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View file

@ -6227,7 +6227,7 @@ impl MultiBufferSnapshot {
cursor.seek_to_start_of_current_excerpt();
let region = cursor.region()?;
let offset = region.range.start;
let buffer_offset = region.buffer_range.start;
let buffer_offset = start_excerpt.buffer_start_offset();
let excerpt_offset = cursor.excerpts.start().clone();
Some(MultiBufferExcerpt {
diff_transforms: cursor.diff_transforms,

View file

@ -2842,6 +2842,22 @@ async fn test_random_multibuffer(cx: &mut TestAppContext, mut rng: StdRng) {
.unwrap()
+ 1
);
let reference_ranges = cx.update(|cx| {
reference
.excerpts
.iter()
.map(|excerpt| {
(
excerpt.id,
excerpt.range.to_offset(&excerpt.buffer.read(cx).snapshot()),
)
})
.collect::<HashMap<_, _>>()
});
for i in 0..snapshot.len() {
let excerpt = snapshot.excerpt_containing(i..i).unwrap();
assert_eq!(excerpt.buffer_range(), reference_ranges[&excerpt.id()]);
}
assert_consistent_line_numbers(&snapshot);
assert_position_translation(&snapshot);