From cbc0bf44522152d12a05217472ba2a54aaad8ea8 Mon Sep 17 00:00:00 2001 From: kamkow1 Date: Sun, 8 Mar 2026 12:35:39 +0100 Subject: [PATCH] CE edit handle backspace deletion into previous line --- ce/edit.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ce/edit.c b/ce/edit.c index fd1a4be..d2457f3 100644 --- a/ce/edit.c +++ b/ce/edit.c @@ -227,6 +227,24 @@ void edit_start (const char* file_path, const char* text) { gapbuffer_move (&editor.current_line->gb, editor.cursor.col); editor.cursor.col--; gapbuffer_backspace (&editor.current_line->gb); + } else { + if (editor.cursor.line > 0) { + struct list_node_link* prev = editor.current_line->lines_link.prev; + struct edit_line* prev_line = list_entry (prev, struct edit_line, lines_link); + + size_t prev_len = gapbuffer_length (&prev_line->gb); + + gapbuffer_concat (&wrealloc, NULL, &prev_line->gb, &editor.current_line->gb); + + list_remove (editor.lines, &editor.current_line->lines_link); + free (editor.current_line->gb.buffer); + free (editor.current_line); + editor.current_line = prev_line; + + editor.cursor.col = prev_len; + editor.cursor.line--; + editor.total_lines--; + } } } break;