Provide an accurate panic message when translating points off the end of a line
Nathan Sobo
created
Maybe we should fail more gracefully in this case, but I think we should at least make the message accurate and see how we do.
Change summary
crates/text/src/rope.rs | 6 ++++++
1 file changed, 6 insertions(+)
Detailed changes
@@ -565,6 +565,12 @@ impl Chunk {
if ch == '\n' {
point.row += 1;
+ if point.row > target.row {
+ panic!(
+ "point {:?} is beyond the end of a line with length {}",
+ target, point.column
+ );
+ }
point.column = 0;
} else {
point.column += ch.len_utf8() as u32;