Skip to content

Reject table row and column resizes past the table - #2273

Open
chamber074 wants to merge 1 commit into
storytold:mainfrom
chamber074:fix/table-resize-range-2260
Open

chamber074 wants to merge 1 commit into
storytold:mainfrom
chamber074:fix/table-resize-range-2260

Conversation

@chamber074

@chamber074 chamber074 commented Nov 20, 2026 •

Copy link
Copy Markdown

Fixes #2260.

table.rowHeight and table.columnWidth accepted positive indices past the end of the table and reported success — row: 99 on a 2-row table returned Ok and could commit history. #1189 rejected malformed indices (negative, fractional); its review identified out-of-range positive indices as this follow-up.

Changes

  • crates/engine/src/cmd/table.rs: both resize handlers now check the index against the table's row/column count before mutating, returning the same invalid-argument error shape as the Reject invalid row/col index in table row and column commands #1189 errors (e.g. col 99 is out of range: the table has 2 columns). The check runs inside the edit step, which works on a clone, so a refused resize changes nothing and pushes no history. The fallback for an absent row/col is unchanged, and valid resizes (including keepTotal and the drag tool) behave as before.

Tests

  • table_resize_rejects_a_row_or_column_past_the_table — on a 2 × 2 table with a redo step waiting, row 2 and 99, col 2 and 99 (with and without keepTotal), and col u64::MAX each error; the presentation object is untouched, undo/redo lengths are unchanged, and redo afterwards still works.
  • table_resize_in_range_still_works — in-range row and column resizes succeed, one undo step each.
  • One existing test changed: table_column_width_of_a_huge_column_is_ignored asserted that col: u64::MAX returns Ok and changes nothing. That expectation is the behavior Table resize commands report success for a row or column outside the table #2260 reports, so the case now lives in the rejects test above (still no crash, still no change — just an error instead of silent Ok).

Fail-before on unmodified main: the rejects test fails at its first case; the in-range test passes.

Verified locally with cargo xtask ci: every step passes except backstage::tests::start_screen_opens_the_palette_and_preferences (ui-egui), which fails identically on unmodified main in this environment.

Drafted with AI assistance; verified and shipped by the contributor.

Summary by CodeRabbit

  • Bug Fixes
    • Table row-height and column-width adjustments now reject indices outside the table’s dimensions with a clear error.
    • Rejected adjustments leave the table and undo/redo history unchanged. Valid adjustments continue to work as expected.

table.rowHeight and table.columnWidth accepted a row or column the table
doesn't have (row 99 on a 2 x 2 table) and reported success. Both now return
an invalid-argument error, checked inside the edit before any change, so a
refused resize leaves the presentation and the undo and redo history as they
were. This is the follow-up storytold#1189's review named.

The old test that expected a huge col to be ignored now expects the error.
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Row-height and column-width commands now reject indices outside the table dimensions. Tests verify rejected commands preserve the presentation and undo/redo history, while valid resize commands continue to work.

Changes: Table Resize Validation

Layer / File(s) Summary
Validate row and column resize indices
crates/engine/src/cmd/table.rs, crates/engine/src/tests.rs
The resize commands validate indices against the table dimensions and return errors for out-of-range indices. Tests check that rejection preserves the presentation and undo/redo history, and that valid resizes still work.

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

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: silvertree2010, echelon, zberry

Merge Risk: Minimal · up to 4ca6a

Row-height and column-width commands now return an invalid-argument error for rows or columns that do not exist, while valid resizes behave as before. No remaining merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: table.rowHeight and table.columnWidth now reject row or column indices past the table size. The raw summary confirms column_width and row_height validate indices in t…
Linked Issues check Passed Issue #2260 requires that table.rowHeight and table.columnWidth return an invalid-argument error for a positive row or column index outside the table, without changing the presentation or undo/red…
Out of Scope Changes check Passed All changes fall within the scope of #2260. The production change is limited to the column_width and row_height handlers in crates/engine/src/cmd/table.rs. The test changes add the rejects and i…
Full details: Title check

Explanation

The title states the main change: table.rowHeight and table.columnWidth now reject row or column indices past the table size. The raw summary confirms column_width and row_height validate indices in the edit, and the tests check out-of-range rejection. The title is short and specific and does not describe unrelated work.

Full details: Linked Issues check

Explanation

Issue #2260 requires that table.rowHeight and table.columnWidth return an invalid-argument error for a positive row or column index outside the table, without changing the presentation or undo/redo state, and that valid resizes keep working. The PR summary states that both handlers check the index against the table's row or column count inside the edit step, which works on a clone, and return an error that names the parameter and table size. The raw summary of crates/engine/src/cmd/table.rs (+8/-0) reports the same check and states that the refused resize creates no undo step. The new test table_resize_rejects_a_row_or_column_past_the_table covers row 2 and 99, col 2 and 99 (with and without keepTotal), and u64::MAX, and checks state and history. The test table_resize_in_range_still_works covers valid resizes. Limitation: the repository diff tool could not read the changed blobs, so the handler code was not read directly. This verdict rests on the PR summary, the raw summary, and the PR description, which agree.

Full details: Out of Scope Changes check

Explanation

All changes fall within the scope of #2260. The production change is limited to the column_width and row_height handlers in crates/engine/src/cmd/table.rs. The test changes add the rejects and in-range tests. The one modified existing test, table_column_width_of_a_huge_column_is_ignored, asserted the Ok result that #2260 reports as the defect. Its case moves into the rejects test, which keeps the no-crash and no-change checks. The PR states that the missing row/col fallback and valid resizes, including keepTotal and the drag tool, are unchanged. No unrelated changes appear in the summaries. Limitation: the changed file contents could not be read directly, so this verdict relies on the summaries.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 5b422e8 and 4ca6a79.

Files selected for processing: 2

  • crates/engine/src/cmd/table.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; 7 remain after this review.

@autocraft-bot autocraft-bot Bot added the bugfix Fixes something that is broken: wrong result, crash, data loss label Nov 21, 2026

@autocraft-bot autocraft-bot Bot 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.

AI-generated review (Claude Opus 5.5). Not a maintainer decision.

No blocking problems found.

Both table resize commands now check the row or column index against the table before changing anything, so an index past the end of the table returns an error and leaves the presentation and undo/redo history untouched.

  • The check runs inside the table edit (crates/engine/src/cmd/table.rs:640 and :669), so a refused resize changes nothing and adds no undo step; the new test confirms the document is still the same object and the history lengths stay the same.
  • The error comes from the same bad(...) helper as the malformed-index errors and names the command, the key, the index and the table's size (crates/engine/src/cmd/table.rs:631-633).
  • The drag tool (crates/engine/src/tools/drag.rs:183-185) only passes borders that exist in the table, so dragged resizes are not affected.
  • Replacing the old test that expected col: u64::MAX to succeed is consistent with the issue; the same input is still covered by the rejection test.

Claims checked:

  • verified: table.rowHeight and table.columnWidth reject a positive row/col past the end of the table with an invalid-argument error (crates/engine/src/cmd/table.rs:631-633 index_in_table errors when i >= n; called at crates/engine/src/cmd/table.rs:640 with t.n_cols() and crates/engine/src/cmd/table.rs:669 wit…
  • verified: A refused resize changes nothing and pushes no history (The check runs inside the with_table closure (crates/engine/src/cmd/table.rs:295 f(t)?) inside edit_shapes/s.edit (crates/engine/src/cmd.rs:485-499), which propagates the error; crates/engine/src/tests.rs test asserts Arc::ptr_eq on the doc an…
  • verified: The fallback for an absent row/col and valid resizes (including keepTotal and the drag tool) behave as before (crates/engine/src/cmd/table.rs:266-270 at() unchanged; resize logic at crates/engine/src/cmd/table.rs:643-673 unchanged; crates/engine/src/tools/drag.rs:183-185 passes border indices from…

Reviewed at 4ca6a79.

Recommendation: merge, after a maintainer's decision.

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

bugfix Fixes something that is broken: wrong result, crash, data loss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Table resize commands report success for a row or column outside the table

1 participant