Skip to content

Commit

Permalink
Validate buffer_id of anchors in is_valid (cherry-pick #11170) (#11172)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
gcp-cherry-pick-bot[bot] and ConradIrwin committed Apr 29, 2024
1 parent 5929bc3 commit 6b64abf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/text/src/anchor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)>();
Expand Down

0 comments on commit 6b64abf

Please sign in to comment.