Skip to content

fix(autosum): stop the guessed range at a blank cell - #3309

Merged
FredApps merged 1 commit into
storytold:mainfrom
vangel76:fix-autosum-gap-3291
Nov 7, 2026
Merged

FredApps merged 1 commit into
storytold:mainfrom
vangel76:fix-autosum-gap-3291

Conversation

@vangel76

@vangel76 vangel76 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3291

AutoSum on a single cell guessed its range upward and stepped over one blank cell when a number sat above the gap. With a block of numbers, a total, a blank row and a second block, the second total therefore summed both blocks (and the first total). The guess now stops at the first cell that isn't a number, as Excel does and as the leftward guess already did.

Tested: new engine test autosum_of_a_single_cell_stops_at_a_blank_cell (issue layout; failed before with 42 instead of 30, passes now). Engine crate tests (831) and clippy -D warnings pass; workspace nextest passes except UI tests that panic on missing glyphs in this environment (no CJK fonts).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • AutoSum now stops at blank cells when inferring a numeric range, so separate blocks of numbers aren’t included in the same total.

The single-cell AutoSum guess stepped over one blank cell when a number sat
above it, so a second block of numbers below a gap was summed together with
the first block. It now stops at the first non-number, as Excel does.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

AutoSum now stops its upward scan at the first nonnumeric cell. A regression test checks that a blank row separates the inferred range from an earlier numeric block and its total.

Changes: AutoSum range inference

Layer / File(s) Summary
Stop range inference at blanks
crates/engine/src/cmd/formulas.rs, crates/engine/src/tests.rs
The upward scan stops at the first nonnumeric cell. A regression test checks that AutoSum at B11 sums only the lower numeric block and returns 30.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: prxnvt

Merge Risk: Minimal · up to 1ff10

No concrete merge-blocking risk is established for this focused AutoSum fix.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: AutoSum now stops the guessed range at a blank cell.
Linked Issues check Passed Issue #3291 requires AutoSum below a second numeric block to exclude an earlier block separated by a blank row. guessed_range now scans upward only through contiguous numeric cells. The new test `au…
Out of Scope Changes check Passed The pull request changes only the AutoSum range-guess logic and adds a regression test for issue #3291. Both changes directly support the linked issue. No unrelated changes are shown.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

Issue #3291 requires AutoSum below a second numeric block to exclude an earlier block separated by a blank row. guessed_range now scans upward only through contiguous numeric cells. The new test autosum_of_a_single_cell_stops_at_a_blank_cell creates the issue layout and verifies that B11 returns 30 for the lower block.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Clippy (1.99.0)

Clippy execution timed out

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between df137b8 and 1ff10df.

Files selected for processing: 2
  • crates/engine/src/cmd/formulas.rs
  • crates/engine/src/tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

@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.

Reviewed current head 1ff10df55756d3823bcf91e3d3fc31462b6276b4. No findings. I checked the complete diff, guessed_range and its caller: the upward scan now stops at the first nonnumeric cell, preserves row-zero bounds and the existing leftward fallback, and does not change explicit-range AutoSum. The new regression exercises separate blocks with a prior subtotal and verifies 30 rather than double-counting that earlier block.

The current-head cargo xtask ci log includes the new autosum_of_a_single_cell_stops_at_a_blank_cell test passing; 3,374 tests passed with 1 skipped. I relied on that CI execution rather than claiming a new local run. Approved.

Verified gate.

@FredApps
FredApps merged commit b9e5e0f into storytold:main Nov 7, 2026
6 checks passed
@FredApps

FredApps commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Merged reviewed head 1ff10df55756d3823bcf91e3d3fc31462b6276b4 into main as b9e5e0ff892578ba4d0a811477f30695cd1a31bf after rechecking the approval, current checks, and mergeability. The applicable CI gate was green before merging.

Review: #3309 (review)

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.

bug: sum is calculated over all cells in a column if only one empty row is set

2 participants