feat(table_core,virtual_table): Propagate injection info on commit
RowCommitInfo now includes: - is_injected: bool (was this an injected row) - injection_index: ?usize (where it was injected) buildCommitInfo() copies these from RowEditBuffer. VirtualAdvancedTable sets result.injection_committed and result.injection_row_idx when committing an injected row, for both Tab navigation and selection change commits. This allows the panel to know when to INSERT vs UPDATE and handle the special case of locally injected rows.
This commit is contained in:
parent
47146b75c9
commit
08b10486d2
2 changed files with 32 additions and 0 deletions
|
|
@ -1413,6 +1413,12 @@ pub const RowCommitInfo = struct {
|
|||
|
||||
/// Número de cambios
|
||||
change_count: usize,
|
||||
|
||||
/// True si era una fila inyectada (Ctrl+N entre líneas)
|
||||
is_injected: bool = false,
|
||||
|
||||
/// Índice visual donde fue inyectada (válido si is_injected = true)
|
||||
injection_index: ?usize = null,
|
||||
};
|
||||
|
||||
/// Construye la info de commit desde un RowEditBuffer
|
||||
|
|
@ -1439,6 +1445,8 @@ pub fn buildCommitInfo(
|
|||
.is_insert = buffer.is_new_row,
|
||||
.changes = changes_out[0..count],
|
||||
.change_count = count,
|
||||
.is_injected = buffer.is_injected,
|
||||
.injection_index = buffer.injection_index,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -490,6 +490,12 @@ pub fn virtualAdvancedTableRect(
|
|||
result.row_commit_is_insert = info.is_insert;
|
||||
result.row_changes_count = info.change_count;
|
||||
result.row_changed = true;
|
||||
|
||||
// Propagar info de inyección si aplica
|
||||
if (info.is_injected) {
|
||||
result.injection_committed = true;
|
||||
result.injection_row_idx = info.injection_index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -510,6 +516,12 @@ pub fn virtualAdvancedTableRect(
|
|||
result.row_commit_is_insert = info.is_insert;
|
||||
result.row_changes_count = info.change_count;
|
||||
result.row_changed = true;
|
||||
|
||||
// Propagar info de inyección si aplica
|
||||
if (info.is_injected) {
|
||||
result.injection_committed = true;
|
||||
result.injection_row_idx = info.injection_index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -529,6 +541,10 @@ pub fn virtualAdvancedTableRect(
|
|||
const new_row_idx = list_state.getSelectedRow() orelse 0;
|
||||
const is_ghost = table_core.isGhostRow(new_row_id);
|
||||
|
||||
// Detectar si estamos abandonando una fila inyectada
|
||||
const was_injected = list_state.row_edit_buffer.is_injected;
|
||||
const injection_idx = list_state.row_edit_buffer.injection_index;
|
||||
|
||||
// checkRowChangeAndCommit compara row_ids y hace commit si son diferentes
|
||||
if (table_core.checkRowChangeAndCommit(
|
||||
&list_state.row_edit_buffer,
|
||||
|
|
@ -542,6 +558,14 @@ pub fn virtualAdvancedTableRect(
|
|||
result.row_commit_is_insert = commit_info.is_insert;
|
||||
result.row_changes_count = commit_info.change_count;
|
||||
|
||||
// Si era una fila inyectada, señalar para que el panel haga INSERT
|
||||
if (was_injected) {
|
||||
result.injection_committed = true;
|
||||
result.injection_row_idx = injection_idx;
|
||||
// Mantener injected_row_idx en state para renderizado
|
||||
// (se limpiará cuando el scroll la saque del viewport)
|
||||
}
|
||||
|
||||
// Compatibilidad
|
||||
result.row_changed = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue