Fix bugs in {prev,next}_row_boundary

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld
2021-07-30 09:50:28 -07:00
co-authored by Nathan Sobo
parent 05f8a61bc8
commit 82ed33a924
3 changed files with 61 additions and 40 deletions
+5
View File
@@ -497,6 +497,11 @@ impl Snapshot {
self.chunks_at(FoldOffset(0)).collect()
}
#[cfg(test)]
pub fn fold_count(&self) -> usize {
self.folds.items(&self.buffer_snapshot).len()
}
pub fn text_summary_for_range(&self, range: Range<FoldPoint>) -> TextSummary {
let mut summary = TextSummary::default();
+7 -4
View File
@@ -495,7 +495,7 @@ impl Snapshot {
}
pub fn max_point(&self) -> WrapPoint {
self.to_wrap_point(self.tab_snapshot.max_point())
self.to_wrap_point(self.tab_snapshot.max_point(), Bias::Right)
}
pub fn line_len(&self, row: u32) -> u32 {
@@ -548,9 +548,9 @@ impl Snapshot {
TabPoint(tab_point)
}
pub fn to_wrap_point(&self, point: TabPoint) -> WrapPoint {
pub fn to_wrap_point(&self, point: TabPoint, bias: Bias) -> WrapPoint {
let mut cursor = self.transforms.cursor::<TabPoint, WrapPoint>();
cursor.seek(&point, Bias::Right, &());
cursor.seek(&point, bias, &());
WrapPoint(cursor.sum_start().0 + (point.0 - cursor.seek_start().0))
}
@@ -564,7 +564,10 @@ impl Snapshot {
}
}
self.to_wrap_point(self.tab_snapshot.clip_point(self.to_tab_point(point), bias))
self.to_wrap_point(
self.tab_snapshot.clip_point(self.to_tab_point(point), bias),
bias,
)
}
fn check_invariants(&self) {