Skip to content

Refuse inserting cells that would push values off the worksheet (#580) - #584

Merged
aiongg merged 1 commit into
storytold:mainfrom
MarekSpodBiedry:issue-580
Oct 22, 2026
Merged

aiongg merged 1 commit into
storytold:mainfrom
MarekSpodBiedry:issue-580

Conversation

@MarekSpodBiedry

Copy link
Copy Markdown
Contributor

Fixes #580.

home.insertCells with shift: "right" or "down" moved the cells and quietly dropped any cell that landed past column XFD or row 1048576 (shift_cols_in_rows / shift_rows_in_cols keep only moved cells that are still on the sheet). In the issue's repro, a value in XFD1 or A1048576 was lost after inserting at A1, and the saved file did not have it either.

Before it edits anything, insert_cells now checks the cells that would be pushed off: the last width columns of the affected rows (shift right) or the last height rows of the affected columns (shift down), but only from the inserted range onward. If any of them has a value or a formula, the command fails and the workbook stays unchanged. The error text is the same "To prevent possible loss of data, Excel cannot shift nonblank cells off of the worksheet." message that insert_lines already uses for whole rows and columns. The table-header insert in insert.rs makes the same nonblank check (value or formula). Values that still fit move as before, and the entire-row/entire-column shift modes still go through insert_lines.

Test inserting_cells_refuses_to_push_values_off_the_sheet in crates/engine/src/tests.rs covers both directions with the issue's fixtures:

  • A1=1 plus XFD1=2 (right) or A1048576=2 (down): the insertion fails with the loss-of-data error and both values stay where they were. On main the insertion succeeds, so the test fails.
  • XFC1 → XFD1 and A1048575 → A1048576: a value that still fits moves to the last valid cell.

@scottcampbelldata

scottcampbelldata commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

The old-base CSV failures are addressed by incorporating the existing upstream fix, while preserving your worksheet-boundary insertion guard and regression tests. The refreshed source passed all eight Ubuntu cargo xtask ci gates and matched the frozen validation tree throughout the run.

Follow-up to your existing branch: MarekSpodBiedry#5 (commit 9be6cf25).

jesusthehelper-oss added a commit to jesusthehelper-oss/gridcraft that referenced this pull request Oct 19, 2026
@aiongg
aiongg merged commit 947930e into storytold:main Oct 22, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(sheet): partial cell insertion silently deletes values at worksheet boundaries

3 participants