Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete empty cells #494

Merged
merged 9 commits into from
May 22, 2023
24 changes: 11 additions & 13 deletions src/grid/actions/DeleteCells.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@ interface DeleteCellsArgs {
export const DeleteCells = async (args: DeleteCellsArgs) => {
const { x0, y0, x1, y1, sheetController, pyodide, app, create_transaction } = args;

const cells_to_delete = sheetController.sheet.grid.getNakedCells(x0, y0, x1, y1);
if (!cells_to_delete.length) return;

if (create_transaction ?? true) sheetController.start_transaction();

// delete cells row by row
for (var current_row = y0; current_row <= y1; current_row++) {
const cells_to_delete = sheetController.sheet.grid.getNakedCells(x0, current_row, x1, current_row);
// delete cells
await updateCellAndDCells({
starting_cells: cells_to_delete,
sheetController,
pyodide,
delete_starting_cells: true,
app,
create_transaction: false,
});
}
await updateCellAndDCells({
starting_cells: cells_to_delete,
sheetController,
pyodide,
delete_starting_cells: true,
app,
create_transaction: false,
});

if (create_transaction ?? true) sheetController.end_transaction();
};