Skip to content

engine: pageLayout.printTitles only touches the axes it is given - #1527

Merged
aiongg merged 1 commit into
storytold:mainfrom
midasmatterhorn:fix/r4-print-titles-axis
Oct 22, 2026
Merged

aiongg merged 1 commit into
storytold:mainfrom
midasmatterhorn:fix/r4-print-titles-axis

Conversation

@midasmatterhorn

Copy link
Copy Markdown
Contributor

print_titles reads both rows and cols into Options and assigns both unconditionally (crates/engine/src/cmd/view.rs:234), so pageLayout.printTitles {"rows":"2:2"} sets title_cols = None and {"cols":"A:A"} sets title_rows = None: the repeated columns (or rows) disappear from every printed page, with no message and no way to set or clear just one axis. Reachable from any programmatic caller — control channel, MCP execute_command, or the CLI.

The sibling command already reads these the right way: pageLayout.pageSetup distinguishes "key absent" (leave alone) from "key present but empty/null" (clear) via Option<Option<..>> (crates/engine/src/cmd/print.rs:1612). The two commands disagree about the same two settings today.

Fix: read both axes the way pageSetup does — an absent key leaves that axis alone, an empty/null value clears it, and anything else that isn't a range is an error rather than a silent wipe.

Regression test: print_titles_keeps_the_axis_it_is_not_given — on main the rows-only call clears the columns (left: (Some((1, 1)), None)); with the fix each axis is touched only when named, an explicit empty value still clears that axis on purpose, and a bad range errors. Full gridcraft-engine lib suite green (287 passed).

print_titles read both rows and cols as Options and assigned both
unconditionally, so {"rows":"2:2"} set title_cols = None and
{"cols":"A:A"} set title_rows = None: the repeated rows or columns
disappeared from every printed page with no message, and there was no
way to set or clear just one axis. The sibling pageLayout.pageSetup
already distinguishes "key absent" from "key present but empty"; read
both axes the same way — absent leaves the axis alone, empty/null clears
it, anything else that is not a range is an error rather than a silent
wipe.

Regression test: print_titles_keeps_the_axis_it_is_not_given — on main
the rows-only call clears the columns; with the fix each axis is touched
only when named, an explicit empty value still clears, and a bad range
errors.
@MichaelMuClaude

Copy link
Copy Markdown

Verified against main (applies clean):

  • Isolated just the new test and ran it alone against unpatched main: fails exactly as quoted — {"rows":"2:2"} alone leaves (Some((1, 1)), None), clearing the columns that were never named.
  • Applied the full patch: cargo test -p gridcraft-engine --lib → 288/288 passed, matching "full gridcraft-engine lib suite green (287 passed)" (one more than quoted, presumably a test landed on main since the PR was written — not a discrepancy).
  • cargo clippy -p gridcraft-engine --lib --tests -- -D warnings and cargo fmt --check -p gridcraft-engine both clean.
  • The three-way absent / null-or-empty / range-or-error split in the new axis closure is exactly the shape needed to distinguish "don't touch" from "clear" from "bad input," and all four of the test's scenarios (both named, one named, explicit clear, bad range) are covered and pass.

Correct and precisely targeted at the actual bug (the unconditional double-assignment), matching the sibling pageSetup command's existing convention. Good to merge.

@aiongg
aiongg merged commit cede13d into storytold:main Oct 22, 2026
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.

3 participants