Improve panic message for invalid anchors (#7700)
Release Notes: - N/A Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
parent
48a4cbad37
commit
ede9600ab4
1 changed files with 24 additions and 4 deletions
|
@ -1911,8 +1911,16 @@ impl BufferSnapshot {
|
||||||
} else {
|
} else {
|
||||||
insertion_cursor.prev(&());
|
insertion_cursor.prev(&());
|
||||||
}
|
}
|
||||||
let insertion = insertion_cursor.item().expect("invalid insertion");
|
|
||||||
assert_eq!(insertion.timestamp, anchor.timestamp, "invalid insertion");
|
let Some(insertion) = insertion_cursor
|
||||||
|
.item()
|
||||||
|
.filter(|insertion| insertion.timestamp == anchor.timestamp)
|
||||||
|
else {
|
||||||
|
panic!(
|
||||||
|
"invalid anchor {:?}. buffer id: {}, version: {:?}",
|
||||||
|
anchor, self.remote_id, self.version
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
let mut fragment_cursor = self.fragments.cursor::<(Option<&Locator>, usize)>();
|
let mut fragment_cursor = self.fragments.cursor::<(Option<&Locator>, usize)>();
|
||||||
fragment_cursor.seek(&Some(&insertion.fragment_id), Bias::Left, &None);
|
fragment_cursor.seek(&Some(&insertion.fragment_id), Bias::Left, &None);
|
||||||
|
@ -1949,8 +1957,20 @@ impl BufferSnapshot {
|
||||||
} else {
|
} else {
|
||||||
insertion_cursor.prev(&());
|
insertion_cursor.prev(&());
|
||||||
}
|
}
|
||||||
let insertion = insertion_cursor.item().expect("invalid insertion");
|
|
||||||
debug_assert_eq!(insertion.timestamp, anchor.timestamp, "invalid insertion");
|
let Some(insertion) = insertion_cursor.item().filter(|insertion| {
|
||||||
|
if cfg!(debug_assertions) {
|
||||||
|
insertion.timestamp == anchor.timestamp
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}) else {
|
||||||
|
panic!(
|
||||||
|
"invalid anchor {:?}. buffer id: {}, version: {:?}",
|
||||||
|
anchor, self.remote_id, self.version
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
&insertion.fragment_id
|
&insertion.fragment_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue