summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-23 13:02:40 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-23 13:02:40 -0300
commita1a381926626aa44e264cd24dbf35e26f3d52330 (patch)
tree7e2af5d430e70903a4d8cb0202f667bb3d01f77b
parent88ca0bf25d072e73f31c0441b0ba05f403898b37 (diff)
downloadjet-a1a381926626aa44e264cd24dbf35e26f3d52330.tar.gz
jet-a1a381926626aa44e264cd24dbf35e26f3d52330.zip
Fix not deleting at gap_start when not empty
-rw-r--r--point.c13
1 files 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);
}