Skip to content

Sort: a Sheet! prefix on the range sorts that sheet, not the active one - #1284

Merged
aiongg merged 1 commit into
storytold:mainfrom
marcoarnulfo:fix/sort-sheet-prefix
Oct 22, 2026
Merged

aiongg merged 1 commit into
storytold:mainfrom
marcoarnulfo:fix/sort-sheet-prefix

Conversation

@marcoarnulfo

Copy link
Copy Markdown
Contributor

Fixes #1283.

do_sort always wrote to wb.active_sheet, and data_range dropped the Sheet! prefix of range, so data.sort (and sort_range, which goes through it) sorted the same cells on the active sheet and reported success. Sort now resolves its sheet with the existing target_sheet helper, the way range.setValues and the formatting commands do, and passes it down to do_sort; data.sortAscending/data.sortDescending share that path, so they get the same fix. Following the rule in #885, the selection belongs to the active sheet, so naming another sheet without a range is an error, and so is a prefix that disagrees with sheet. Happy to switch to refusing a prefix that names another sheet instead (the #206 rule for cell references), if you'd rather keep sort on the active sheet.

Thanks @Essermarth for the precise repro. Other data.rs commands still read active_sheet directly (filter, remove duplicates, subtotal, circle invalid data); I left them out to keep this one small, happy to send them as a follow-up.

Validation:

  • tests::sort_with_a_sheet_prefix_sorts_the_named_sheet (the steps from the issue): fails on main (Prices stays p1, p2, p3, Sheet1 gets sorted), passes here
  • cargo test -p gridcraft-engine --lib sort, cargo clippy -p gridcraft-engine --all-targets -- -D warnings, cargo fmt --all -- --check
  • (macOS, Apple silicon)

@Essermarth

Essermarth commented Oct 14, 2026 via email

Copy link
Copy Markdown

@marcoarnulfo

Copy link
Copy Markdown
Contributor Author

Thanks, good to know that's the behaviour you want, I'll keep it. I'll do the follow-up for filter, remove duplicates and subtotal (and the other data.rs commands that read the active sheet) in a separate PR.

aiongg added a commit to aiongg/gridcraft that referenced this pull request Oct 22, 2026
…Filter boxes

Conflicts:
- crates/engine/src/cmd/data.rs: do_sort keeps storytold#1284's sheet parameter and checks Sorting on it; toggle_filter checks Filtering after storytold#1285's data_target
- crates/engine/src/tests.rs: adjacent tests, both kept
@aiongg
aiongg merged commit 87df194 into storytold:main Oct 22, 2026
1 check passed
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.

[0.6.1] data.sort / sort_range ignore a Sheet! prefix and sort the active sheet instead (silent, reports success)

3 participants