Fix crash caused by overflow
@@ -803,7 +803,10 @@ fn event(
editor.cursor =
movement::Cursor::new(
CursorMode::Normal(
- buffer.len() - 1,
+ buffer.offset_line_end(
+ buffer.len(),
+ false,
+ ),
),
None,
);
@@ -812,7 +815,11 @@ fn event(
movement::Cursor::new(
CursorMode::Insert(
Selection::caret(
- buffer.len() - 1,
+ buffer
+ .offset_line_end(
+ buffer.len(),
+ true,
+ ),
),
),
None,
