Validate buffer_id of anchors in is_valid (cherry-pick #11170) (#11171)
gcp-cherry-pick-bot[bot]
and
Conrad Irwin
created
Cherry-picked Validate buffer_id of anchors in is_valid (#11170)
Release Notes:
- Fixes diagnostic panic better (follow up from #11066)
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
Change summary
crates/text/src/anchor.rs | 2 ++
1 file changed, 2 insertions(+)
Detailed changes
@@ -97,6 +97,8 @@ impl Anchor {
pub fn is_valid(&self, buffer: &BufferSnapshot) -> bool {
if *self == Anchor::MIN || *self == Anchor::MAX {
true
+ } else if self.buffer_id != Some(buffer.remote_id) {
+ false
} else {
let fragment_id = buffer.fragment_id_for_anchor(self);
let mut fragment_cursor = buffer.fragments.cursor::<(Option<&Locator>, usize)>();