Always panic if invalid point is passed to {prev,next}_row_boundary
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
This commit is contained in:
parent
0fc2db6d6e
commit
80f3173fbd
1 changed files with 10 additions and 14 deletions
|
@ -204,7 +204,8 @@ impl DisplaySnapshot {
|
||||||
self.buffer_snapshot.max_point().row + 1
|
self.buffer_snapshot.max_point().row + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn prev_row_boundary(&self, mut display_point: DisplayPoint) -> (DisplayPoint, Point) {
|
pub fn prev_row_boundary(&self, input_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);
|
||||||
|
@ -214,17 +215,15 @@ impl DisplaySnapshot {
|
||||||
if next_display_point == display_point {
|
if next_display_point == display_point {
|
||||||
return (display_point, point);
|
return (display_point, point);
|
||||||
}
|
}
|
||||||
debug_assert!(
|
if next_display_point > display_point {
|
||||||
next_display_point < display_point,
|
panic!("invalid display point {:?}", input_display_point);
|
||||||
"{:?} > {:?}",
|
}
|
||||||
next_display_point,
|
|
||||||
display_point
|
|
||||||
);
|
|
||||||
display_point = next_display_point;
|
display_point = next_display_point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_row_boundary(&self, mut display_point: DisplayPoint) -> (DisplayPoint, Point) {
|
pub fn next_row_boundary(&self, input_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 = self.display_point_to_point(display_point, Bias::Right);
|
||||||
|
@ -234,12 +233,9 @@ impl DisplaySnapshot {
|
||||||
if next_display_point == display_point {
|
if next_display_point == display_point {
|
||||||
return (display_point, point);
|
return (display_point, point);
|
||||||
}
|
}
|
||||||
debug_assert!(
|
if next_display_point < display_point {
|
||||||
next_display_point > display_point,
|
panic!("invalid display point {:?}", input_display_point);
|
||||||
"{:?} < {:?}",
|
}
|
||||||
next_display_point,
|
|
||||||
display_point
|
|
||||||
);
|
|
||||||
display_point = next_display_point;
|
display_point = next_display_point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue