From 88ca0bf25d072e73f31c0441b0ba05f403898b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Thu, 23 Apr 2020 11:48:24 -0300 Subject: Fix point movement bug --- point.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'point.c') diff --git a/point.c b/point.c index 7250f2d..5fd02e0 100644 --- a/point.c +++ b/point.c @@ -25,20 +25,20 @@ bool at_eof(struct point *point) { void move_point_forward(struct point *point) { if (point->index < point->page->element_count) { point->index++; - } - if (point->index == point->page->element_count && point->page->next) { - point->index = 0; + } else if (point->page->next) { + point->index = 1; point->page = point->page->next; } } void move_point_backward(struct point *point) { - if (point->index == 0 && point->page->prev) { + if (point->index > 1) { + point->index--; + } else if (point->page->prev) { point->index = point->page->prev->element_count; point->page = point->page->prev; - } - if (point->index > 0) { - point->index--; + } else { + point->index = 0; } } -- cgit v1.2.3