Provide an accurate panic message when translating points off the end of a line

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.
This commit is contained in:
Nathan Sobo 2021-12-29 23:11:54 -08:00
parent 137fbd0088
commit 7c9e4e513c

View File

@ -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;