Invalidate anchors when they get deleted (#14116)

Allows deleting the outputs directly within the editor. This also fixes
the overlap logic to make sure that the ends and the starts are
compared.


https://github.com/zed-industries/zed/assets/836375/84f5f582-95f3-4c6a-a3c9-54da6009e34d

Release Notes:

- N/A

---------

Co-authored-by: Antonio <antonio@zed.dev>
This commit is contained in:
Kyle Kelley 2024-07-11 11:21:41 -07:00 committed by GitHub
parent 018a2a29ea
commit e51d469025
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 72 additions and 9 deletions

View file

@ -131,11 +131,7 @@ impl AnchorRangeExt for Range<Anchor> {
}
fn overlaps(&self, other: &Range<Anchor>, buffer: &MultiBufferSnapshot) -> bool {
let start_cmp = self.start.cmp(&other.start, buffer);
let end_cmp = self.end.cmp(&other.end, buffer);
(start_cmp == Ordering::Less || start_cmp == Ordering::Equal)
&& (end_cmp == Ordering::Greater || end_cmp == Ordering::Equal)
self.end.cmp(&other.start, buffer).is_ge() && self.start.cmp(&other.end, buffer).is_le()
}
fn to_offset(&self, content: &MultiBufferSnapshot) -> Range<usize> {