From 0692b030cbd68842c76d1811b1029d764c5d6c59 Mon Sep 17 00:00:00 2001 From: kamkow1 Date: Sat, 7 Mar 2026 23:49:26 +0100 Subject: [PATCH] CE edit optimize KB_DELETE --- ce/edit.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ce/edit.c b/ce/edit.c index 99d6a9d..b4272f4 100644 --- a/ce/edit.c +++ b/ce/edit.c @@ -271,9 +271,12 @@ void edit_start (const char* file_path, const char* text) { } break; case KB_DELETE: if (editor.mode == EDIT_MODE_NORMAL) { - if (editor.cursor.col < gapbuffer_length (&editor.current_line->gb)) { + size_t len = gapbuffer_length (&editor.current_line->gb); + if (editor.cursor.col < len) { gapbuffer_move (&editor.current_line->gb, editor.cursor.col); - editor.current_line->gb.gap_end++; + + if (editor.current_line->gb.gap_end < editor.current_line->gb.size) + editor.current_line->gb.gap_end++; } } break;