CE edit KB_DELETE the following line
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m2s

This commit is contained in:
2026-03-08 11:55:09 +01:00
parent 0692b030cb
commit 0de0b4c1ae
3 changed files with 26 additions and 2 deletions

View File

@@ -272,11 +272,26 @@ void edit_start (const char* file_path, const char* text) {
case KB_DELETE:
if (editor.mode == EDIT_MODE_NORMAL) {
size_t len = gapbuffer_length (&editor.current_line->gb);
if (editor.cursor.col < len) {
gapbuffer_move (&editor.current_line->gb, editor.cursor.col);
gapbuffer_move (&editor.current_line->gb, editor.cursor.col);
if (editor.cursor.col < len) {
if (editor.current_line->gb.gap_end < editor.current_line->gb.size)
editor.current_line->gb.gap_end++;
} else {
if (editor.cursor.line > 0) {
struct list_node_link* next = editor.current_line->lines_link.next;
struct edit_line* next_line = list_entry (next, struct edit_line, lines_link);
size_t next_len = gapbuffer_length (&next_line->gb);
for (size_t i = 0; i < next_len; i++) {
char chr = gapbuffer_at (&next_line->gb, i);
gapbuffer_insert (&wrealloc, NULL, &editor.current_line->gb, chr);
}
list_remove (editor.lines, &next_line->lines_link);
free (next_line->gb.buffer);
free (next_line);
}
}
}
break;