diff --git a/zed/src/editor/buffer.rs b/zed/src/editor/buffer.rs index 97eb555be4..566446a4e6 100644 --- a/zed/src/editor/buffer.rs +++ b/zed/src/editor/buffer.rs @@ -1679,9 +1679,7 @@ impl Buffer { bias, version, } => { - let mut cursor = self - .fragments - .cursor::(); + let mut cursor = self.fragments.cursor::(); cursor.seek( &VersionedOffset::Offset(*offset), *bias, @@ -1689,12 +1687,12 @@ impl Buffer { ); let fragment = cursor.item().unwrap(); let overshoot = if fragment.visible { - offset - cursor.start().0.offset() + offset - cursor.seek_start().offset() } else { 0 }; - self.text_summary_for_range(0..cursor.start().1 + overshoot) + self.text_summary_for_range(0..cursor.start() + overshoot) } } } @@ -1713,14 +1711,14 @@ impl Buffer { } => { let mut cursor = self .fragments - .cursor::(); + .cursor::(); cursor.seek( &VersionedOffset::Offset(*offset), *bias, &Some(version.clone()), ); - let overshoot = offset - cursor.start().0.offset(); - let summary = cursor.start().1; + let overshoot = offset - cursor.seek_start().offset(); + let summary = cursor.start(); summary.visible + summary.deleted + overshoot } } diff --git a/zed/src/sum_tree.rs b/zed/src/sum_tree.rs index e307d2668b..1cadf1a4d4 100644 --- a/zed/src/sum_tree.rs +++ b/zed/src/sum_tree.rs @@ -37,18 +37,6 @@ impl<'a, T: Summary> Dimension<'a, T> for () { fn add_summary(&mut self, _: &'a T, _: &T::Context) {} } -impl<'a, S, D1, D2> Dimension<'a, S> for (D1, D2) -where - S: Summary, - D1: Dimension<'a, S>, - D2: Dimension<'a, S>, -{ - fn add_summary(&mut self, summary: &'a S, cx: &S::Context) { - self.0.add_summary(summary, cx); - self.1.add_summary(summary, cx); - } -} - pub trait SeekDimension<'a, T: Summary>: Dimension<'a, T> { fn cmp(&self, other: &Self, cx: &T::Context) -> Ordering; } diff --git a/zed/src/sum_tree/cursor.rs b/zed/src/sum_tree/cursor.rs index 8374546a20..6d441133a2 100644 --- a/zed/src/sum_tree/cursor.rs +++ b/zed/src/sum_tree/cursor.rs @@ -45,6 +45,10 @@ where self.sum_dimension = U::default(); } + pub fn seek_start(&self) -> &S { + &self.seek_dimension + } + pub fn start(&self) -> &U { &self.sum_dimension }