fix: avoids panic

This commit is contained in:
Caleb Yates 2024-12-10 17:52:09 +10:00 committed by Jeremy Soller
parent 1f4065c1c3
commit 252078cfe4

View file

@ -1301,7 +1301,7 @@ impl Buffer {
cursor_x_opt = None;
}
Motion::BufferEnd => {
cursor.line = self.lines.len() - 1;
cursor.line = self.lines.len().saturating_sub(1);
cursor.index = self.lines.get(cursor.line)?.text().len();
cursor_x_opt = None;
}