Simplify prev/next_row_boundary methods

We added clipping of points against the buffer when excerpt headers were in the buffer, but now that they're just blocks, I think we can avoid the potential to panic in these methods by going back to not clipping.
This commit is contained in:
Nathan Sobo 2021-12-24 20:50:26 -07:00 committed by Max Brunsfeld
parent d3521650d3
commit 835af35839

View file

@ -200,38 +200,28 @@ impl DisplaySnapshot {
self.buffer_snapshot.max_buffer_row()
}
pub fn prev_row_boundary(&self, input_display_point: DisplayPoint) -> (DisplayPoint, Point) {
let mut display_point = input_display_point;
pub fn prev_row_boundary(&self, mut display_point: DisplayPoint) -> (DisplayPoint, Point) {
loop {
*display_point.column_mut() = 0;
let mut point = display_point.to_point(self);
point = self.buffer_snapshot.clip_point(point, Bias::Left);
point.column = 0;
let next_display_point = self.point_to_display_point_with_clipping(point, Bias::Left);
let next_display_point = self.point_to_display_point(point, Bias::Left);
if next_display_point == display_point {
return (display_point, point);
}
if next_display_point > display_point {
panic!("invalid display point {:?}", input_display_point);
}
display_point = next_display_point;
}
}
pub fn next_row_boundary(&self, input_display_point: DisplayPoint) -> (DisplayPoint, Point) {
let mut display_point = input_display_point;
pub fn next_row_boundary(&self, mut display_point: DisplayPoint) -> (DisplayPoint, Point) {
loop {
*display_point.column_mut() = self.line_len(display_point.row());
let mut point = self.display_point_to_point(display_point, Bias::Right);
point = self.buffer_snapshot.clip_point(point, Bias::Right);
let mut point = display_point.to_point(self);
point.column = self.buffer_snapshot.line_len(point.row);
let next_display_point = self.point_to_display_point(point, Bias::Right);
if next_display_point == display_point {
return (display_point, point);
}
if next_display_point < display_point {
panic!("invalid display point {:?}", input_display_point);
}
display_point = next_display_point;
}
}