mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 04:44:30 +00:00
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:
parent
d3521650d3
commit
835af35839
1 changed files with 4 additions and 14 deletions
|
@ -200,38 +200,28 @@ impl DisplaySnapshot {
|
||||||
self.buffer_snapshot.max_buffer_row()
|
self.buffer_snapshot.max_buffer_row()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn prev_row_boundary(&self, input_display_point: DisplayPoint) -> (DisplayPoint, Point) {
|
pub fn prev_row_boundary(&self, mut display_point: DisplayPoint) -> (DisplayPoint, Point) {
|
||||||
let mut display_point = input_display_point;
|
|
||||||
loop {
|
loop {
|
||||||
*display_point.column_mut() = 0;
|
*display_point.column_mut() = 0;
|
||||||
let mut point = display_point.to_point(self);
|
let mut point = display_point.to_point(self);
|
||||||
point = self.buffer_snapshot.clip_point(point, Bias::Left);
|
|
||||||
point.column = 0;
|
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 {
|
if next_display_point == display_point {
|
||||||
return (display_point, point);
|
return (display_point, point);
|
||||||
}
|
}
|
||||||
if next_display_point > display_point {
|
|
||||||
panic!("invalid display point {:?}", input_display_point);
|
|
||||||
}
|
|
||||||
display_point = next_display_point;
|
display_point = next_display_point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_row_boundary(&self, input_display_point: DisplayPoint) -> (DisplayPoint, Point) {
|
pub fn next_row_boundary(&self, mut display_point: DisplayPoint) -> (DisplayPoint, Point) {
|
||||||
let mut display_point = input_display_point;
|
|
||||||
loop {
|
loop {
|
||||||
*display_point.column_mut() = self.line_len(display_point.row());
|
*display_point.column_mut() = self.line_len(display_point.row());
|
||||||
let mut point = self.display_point_to_point(display_point, Bias::Right);
|
let mut point = display_point.to_point(self);
|
||||||
point = self.buffer_snapshot.clip_point(point, Bias::Right);
|
|
||||||
point.column = self.buffer_snapshot.line_len(point.row);
|
point.column = self.buffer_snapshot.line_len(point.row);
|
||||||
let next_display_point = self.point_to_display_point(point, Bias::Right);
|
let next_display_point = self.point_to_display_point(point, Bias::Right);
|
||||||
if next_display_point == display_point {
|
if next_display_point == display_point {
|
||||||
return (display_point, point);
|
return (display_point, point);
|
||||||
}
|
}
|
||||||
if next_display_point < display_point {
|
|
||||||
panic!("invalid display point {:?}", input_display_point);
|
|
||||||
}
|
|
||||||
display_point = next_display_point;
|
display_point = next_display_point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue