From a1a381926626aa44e264cd24dbf35e26f3d52330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Thu, 23 Apr 2020 13:02:40 -0300 Subject: Fix not deleting at gap_start when not empty --- point.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/point.c b/point.c index 5fd02e0..7977a4e 100644 --- a/point.c +++ b/point.c @@ -65,7 +65,7 @@ void insert_at_point(struct point *point, uint8_t c) { } void delete_at_point(struct point *point) { - if (point->page->element_count == 0) { + if (point->page->element_count == 1) { if (point->page->prev) { point->page = point->page->prev; point->index = point->page->element_count; @@ -74,9 +74,14 @@ void delete_at_point(struct point *point) { point->page = point->page->next; point->index = 0; free_page(point->page->prev); + } else { + align_gap(point); + delete_at_gap(point->page); + move_point_backward(point); } + } else { + align_gap(point); + delete_at_gap(point->page); + move_point_backward(point); } - align_gap(point); - delete_at_gap(point->page); - move_point_backward(point); } -- cgit v1.2.3