Skip to content

fix(engine): keep rule formulas aligned with structural edits - #1656

Open
harrisonoconnorhover wants to merge 2 commits into
storytold:mainfrom
harrisonoconnorhover:codex/structural-rule-formulas
Open

harrisonoconnorhover wants to merge 2 commits into
storytold:mainfrom
harrisonoconnorhover:codex/structural-rule-formulas

Conversation

@harrisonoconnorhover

@harrisonoconnorhover harrisonoconnorhover commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1009.

Inserting or deleting rows, columns or cells moved conditional-format and data-validation ranges without updating their formulas. A rule on C4:C5 reading $A4 moved to C5:C6 but still read $A4, silently changing highlighting and allowed input.

Structural edits now adjust conditional-format expressions, comparison bounds and formula-valued color-scale/data-bar/icon thresholds, plus both validation formulas. References from other sheets also follow the edit. When deletion removes a rule's first application cell or area, per-cell-relative formulas are first rebased to the first surviving old cell. Literal validation lists keep their existing interpretation, including choices that look like cell references.

Tests use synthetic workbooks and check formula text, computed highlighting, bar and icon results, accepted/rejected input, undo/redo and XLSX save/reopen. The original contribution established that five regressions failed on unchanged main with stale coordinates before the fix. Additional coverage checks deleted anchors and all threshold fields. No Excel-based parity measurement is claimed.

Validation on macOS arm64 with Rust 1.99.1:

  • Full cargo run --locked --offline -p xtask -- ci passed all eight gates: formatting, strict workspace/all-target Clippy, workspace tests, assets, layers, WASM, parity and keytips.
  • Workspace tests: 1,617 passed, zero failed, one existing ignored. All six structural-rule regressions passed.
  • The validated source tree 28f166d47a2aca36c7f8a55832930e22c15d4856 is published unchanged as head 02c9f95c662ec2ad7472f8070547a220f4ece13e; the isolated checkout was verified clean at that commit.
  • The follow-up removes one needless borrow in dv.f2.as_deref().map(fix_rule), fixing the Rust 1.99.1 strict-Clippy failure from the original hosted run. No lint suppression or dependency change was added.
  • An initial sandboxed local run could not bind the unchanged synthetic MCP test's loopback socket. The complete rerun with loopback permitted passed, including that test.

The earlier Rust 1.95.0 local run stopped at the unchanged clippy::collapsible_match in crates/xlsx/src/xls/mod.rs:273 on base f1894c6. That historical toolchain result is separate from the passing full Rust 1.99.1 run above. Windows and Linux runtime behavior was not tested locally.

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReviewerA — source-read COMMENT (not an approval)

I read the head of the diff: rule formulas stay aligned with structural edits. The data validation helper is_literal_list decides whether a list source is a typed list (A1,A2 can look like references but is literal choices) or a formula: a source that starts with a quote is literal, and one without ! is literal unless it parses as a reference or a name. Deciding by parsing is better than looking at the text, but a literal list with one item that happens to be a valid name ("Total") is read as a name, which is Excel's behaviour too (a single word in the list box is taken as a name if one exists). Row and column inserts and deletes must adjust the references in rule formulas and leave literal lists alone; a test with insertion above a rule and a literal list is the proof. I have not run it, and no exact-head CI result exists for this head. Nothing was run.

I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.

Status: waiting_author.

This branch has not been deployed

No deployments
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): structural edits move CF and validation ranges without rewriting their formulas

2 participants