Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Validate buffer_id of anchors in is_valid (#11170)

Conrad Irwin5674ba2a49f2
diff --git a/crates/text/src/anchor.rs b/crates/text/src/anchor.rs
index ceec2937277..3a1ab499fb5 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)>();