fix: crash on move_page_down if file size is exactly view size

This commit is contained in:
CJ van den Berg 2024-06-05 21:13:58 +02:00
parent e00ceed052
commit 9371ee2963

View file

@ -95,11 +95,9 @@ pub fn move_page_up(self: *Self, root: Buffer.Root, view: *const View, plane: Pl
} }
pub fn move_page_down(self: *Self, root: Buffer.Root, view: *const View, plane: Plane) void { pub fn move_page_down(self: *Self, root: Buffer.Root, view: *const View, plane: Plane) void {
if (root.lines() < view.rows) { if (root.lines() > self.row + view.rows) {
self.move_buffer_last(root, plane);
} else if (self.row < root.lines() - view.rows - 1) {
self.row += view.rows; self.row += view.rows;
} else self.row = root.lines() - 1; } else self.move_buffer_last(root, plane);
self.follow_target(root, plane); self.follow_target(root, plane);
self.move_left_no_target(root, plane) catch return; self.move_left_no_target(root, plane) catch return;
self.move_right_no_target(root, plane) catch return; self.move_right_no_target(root, plane) catch return;