diff --git a/src/widgets/table_core/keyboard.zig b/src/widgets/table_core/keyboard.zig index 4658ec1..9b9d1e1 100644 --- a/src/widgets/table_core/keyboard.zig +++ b/src/widgets/table_core/keyboard.zig @@ -197,8 +197,15 @@ pub fn handleEditingKeyboard( } // Procesar texto ingresado (caracteres imprimibles) + // FIX: Copiar a buffer local ANTES de modificar edit_buffer (evita corrupción de slice) const text_input = ctx.input.getTextInput(); if (text_input.len > 0) { + // Copiar input a buffer local seguro (en stack) + var local_input: [32]u8 = undefined; + const input_len = @min(text_input.len, local_input.len); + @memcpy(local_input[0..input_len], text_input[0..input_len]); + const safe_input = local_input[0..input_len]; + // Si hay selección, borrarla primero (comportamiento Excel/Word) if (selection_start != null and selection_end != null) { if (selection_start.?.* != selection_end.?.*) { @@ -206,7 +213,7 @@ pub fn handleEditingKeyboard( } } - for (text_input) |ch| { + for (safe_input) |ch| { if (edit_len.* < edit_buffer.len - 1) { // Hacer espacio moviendo caracteres hacia la derecha if (edit_cursor.* < edit_len.*) { diff --git a/src/widgets/virtual_advanced_table/input.zig b/src/widgets/virtual_advanced_table/input.zig index f05c084..42a181d 100644 --- a/src/widgets/virtual_advanced_table/input.zig +++ b/src/widgets/virtual_advanced_table/input.zig @@ -193,6 +193,20 @@ pub fn handleMouseClick( if (data_idx < list_state.current_window.len) { const global_row = list_state.nav.scroll_row + screen_row; + // FIX Bug 2: Si estamos editando y clic en otra fila, hacer commit implícito + if (list_state.isEditing()) { + const editing_row = list_state.cell_edit.edit_row; + if (global_row != editing_row) { + // Commit implícito: clic fuera de la fila en edición + if (list_state.commitEdit()) { + result.cell_committed = true; + result.row_committed = true; + } else { + list_state.cancelEdit(); + } + } + } + // Detect column var clicked_col: usize = 0; const relative_x = mouse.x - bounds.x + list_state.nav.scroll_x;