From 5674ba2a49f285be2cac464fb17ad903999ca4ef Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 29 Apr 2024 10:24:04 -0600 Subject: [PATCH] Validate buffer_id of anchors in is_valid (#11170) Release Notes: - Fixes diagnostic panic better (follow up from #11066) --- crates/text/src/anchor.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/text/src/anchor.rs b/crates/text/src/anchor.rs index ceec293727..3a1ab499fb 100644 --- a/crates/text/src/anchor.rs +++ b/crates/text/src/anchor.rs @@ -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)>();