summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
}