Skip to content

gridcore/gridwasm: 3-D spans shrink on Delete Sheet, x14 DV kept on Any value, wasm sheet.remove rewrites cell formulas (#1734) - #1794

Merged
yeroo merged 9 commits into
mainfrom
issue-1734-leftovers-from-1681-bug-structur
Oct 25, 2026
Merged

yeroo merged 9 commits into
mainfrom
issue-1734-leftovers-from-1681-bug-structur

Conversation

@yeroo

@yeroo yeroo commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Closes #1734 (leftovers from #1681 / PR #1733).

What changed

  • 3-D span shrink (r2-3d). formula::remove_sheet_refs_in_expr(e, removed, order) moves a removed end sheet of a 3-D span inward along the tab order, as Excel does: SUM(Jan:Dec!B2) with Dec deleted is SUM(Jan:Nov!B2); a span left with one sheet is a plain reference (Nov!B2, Nov!B2:C3); none left is #REF!. Applies to cell, table, CF/DV, defined-name and Consolidate rewrites (edit::sheet_order gives the order before removal). The macro-free save's test expectation from Leftovers from #835: bug: structural edits and sheet renames leave conditional formatting and data validation ranges/formulas unshifted #1681 moved accordingly (SUM(Data:Macro1!A1) → SUM(Data!A1)).
  • x14 validations and the dialog (r2-dialog-x14). validation::set_validation with a rule that imposes nothing ("Any value", no messages) cuts only classic rules (edit::clear_classic_validation); an Excel 2010 (extLst) rule the dialog cannot show stays. A real rule still replaces it; Clear All still removes it. Both hosts (suite, xlsxy) share this.
  • Guard tests (r1-guardtests). an_x14_rule_already_named_struck_is_named_once seeds ext_removed and clears through both clear_cond_formats and edit::clear_validation.
  • gridwasm sheet.remove is Delete Sheet (r1-gridwasm). It calls the new SheetPackage::delete_sheet_uncalculated (cell formulas naming the sheet read #REF!; the session's engine does the one recalc). The stash keeps the rewritten cells, table calculated formulas and chart sources; sheet.restore-removed gives them back. A sheet's cell formulas come back only while that sheet is as the removal left it (cell_guards), else they stay and the reply lists the sheet in cellsKept. docs/agent-control.md updated.

Tests

cargo fmt --all --check, cargo clippy -p gridcore -p gridwasm -p xlsxy --all-targets -- -D warnings, cargo test -p gridcore (2066 lib + integration), -p gridwasm (197), -p xlsxy (747+17+2+1), cargo test --manifest-path suite/Cargo.toml (2686+1). No .uit case covers these paths.

Review

  • r1: 1 Major (restored cell formulas matched by (r,c) + identical #REF! text, so a row insert between remove and restore put formulas in the wrong cells) — fixed with per-sheet cell guards; 2 Minor doc fixes; 1 Immaterial (double recalc) fixed.
  • r2: 2 Minor — docs reworded (fixed); a cross-sheet rename/row edit fails a sheet's guard: reported in cellsKept now, a tolerant guard deferred as a follow-up.
  • Plan follow-ups: x14 validations shown in the dialog; gridwasm restore loses the removed sheet's tables.
  • review stopped: round 2 had no Major; 1 minor finding(s) in Leftovers from #1734: bug: structural edits and sheet renames leave conditional formatting and data validation ranges/formulas unshifted #1795

🤖 Generated with Claude Code

https://claude.ai/code/session_011W4RYNZGrXg2wkYTJ9srvr

yeroo and others added 9 commits October 25, 2026 14:15
Excel moves a removed end of Jan:Dec!B2 inward to the nearest sheet of
the span that stays; the rewrite wrote #REF! instead, and saved it.
remove_sheet_refs_in_expr now takes the tab order: a span left with one
sheet is a plain reference, one left with none is #REF!.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016NQQyxNh6BxvvynDtdq9Yi
…ule (#1734)

The dialog shows no Excel 2010 (extLst) validation, so a cell covered
only by one opens as Any value, and since #1681 OK there struck the rule
the user never saw. set_validation now cuts only the classic rules when
the new rule imposes nothing; a real rule still replaces the x14 one and
Clear All still removes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016NQQyxNh6BxvvynDtdq9Yi
cut_ext_rules skips an element ext_removed already names; no load gives
that state, so the guard had no test. Seeded by hand, through both the
conditional-format and the validation clear.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016NQQyxNh6BxvvynDtdq9Yi
…rites back (#1734)

The VS Code/JetBrains tab's sheet.remove called remove_sheet, so cell
formulas naming the sheet kept their text while the suite and xlsxy read
#REF!. It now calls delete_sheet and stashes each other sheet's cell
formula, table calculated formula and in-memory chart it changed;
sheet.restore-removed puts back those still as the removal left them,
and the engine rebuild recalculates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016NQQyxNh6BxvvynDtdq9Yi
The macro sheet removal goes through the same rewrite, so the #1681
test's Data:Macro1 span now reads Data!A1 rather than #REF!.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016NQQyxNh6BxvvynDtdq9Yi
…eet without its recalc (#1734 r1 m1 m2 i1)

The callers of remove_sheet_refs_in_expr still said every reference to a
removed sheet reads #REF!. delete_sheet_uncalculated is the delete
without the recalculation, for a host whose own engine runs the one
recalc on its clock (gridwasm did two).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016NQQyxNh6BxvvynDtdq9Yi
…oval left it (#1734 r1 M1)

The rewrites make a filled column one text (=A!B1*2.. all read #REF!*2),
so matching a stashed cell by place and text let a row insert, a delete
or a move give a cell another's formula. The stash now keeps what each
such sheet's cells held after the removal, and the restore skips a sheet
where any of them changed. sheet.remove also runs one recalculation now,
the engine rebuild's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016NQQyxNh6BxvvynDtdq9Yi
…it kept (#1734 r2)

A sheet's cell formulas come back only while the sheet is as the removal
left it; the docs said each came back unless it changed, and the reply
said nothing when a sheet was skipped. It now lists such sheets in
cellsKept, and the docs say the rule and its limit (a rename or a row or
column edit elsewhere that rewrote a formula there counts as an edit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016NQQyxNh6BxvvynDtdq9Yi
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 98.19495% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
gridwasm/src/bridge.rs 97.14% 10 Missing ⚠️

📢 Thoughts on this report? Let us know!

@yeroo
yeroo merged commit 302a771 into main Oct 25, 2026
14 checks passed
@yeroo
yeroo deleted the issue-1734-leftovers-from-1681-bug-structur branch October 25, 2026 12:54
@yeroo

yeroo commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Merged automatically (auto-merge is on for this checkout): review stopped: round 2 had no Major; 1 minor finding(s) in #1795; merge rounds: none; whole suite green on 691c7c7 (8626 workspace + 2687 suite tests); CI 14/14 passed; merge-check ok.

Follow-ups, all in the leftovers issue #1795 (none reported again elsewhere):

  • plan-x14-dialog (minor, plan v1): Data Validation dialog: show Excel 2010 (x14) validations
  • plan-wasm-tables (minor, plan v1): gridwasm sheet.restore-removed loses the removed sheet's tables
  • r2-guard (minor, review r2): another sheet's rename or row/column edit stops a sheet's cell formulas coming back (now reported in cellsKept)

No finding ended disputed.

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.

Leftovers from #1681: bug: structural edits and sheet renames leave conditional formatting and data validation ranges/formulas unshifted

2 participants