You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(layers): Paste Layers keeps a group's drawing order when a subgroup sits between its layers (#3353) - #3653
Paste Layers (layer.paste) put a copied group's layers in the wrong drawing order when a subgroup sits between the parent's own layers: for P holding A, Q (with B) and C, the paste came in as A, C, B.
place adds the copied groups outermost first, and Map::add_group gathers the new group's layers right away. When P was added, Q did not exist yet, so only A and C were gathered and B was left below them. Opening a project does not do this, because tidy_groups gathers once every group exists.
New Map::restore_order(ids) puts the listed layers back in that order, in the places they now take in the drawing order; other layers stay where they are. Tile layers drawn over a layer that moves are handed down as release_tiles does, and settle_tiles runs after. It does nothing when the layers are already in order.
place (crates/engine/src/cmd/layer_copy.rs) calls it with the pasted layers once every group is in, then gathers each pasted group again, outermost first. The second step only matters when a clipboard holds a group's layers apart, which only a hand-built one does; it is a no-op otherwise.
layer.addLayerFile for a group file uses place too, so it gets the same fix. Its repair of the map already gathers groups, so a group file that splits a group was already put together.
No command or parameter changes, so command-surface.txt is unchanged. No new interface text.
Surfaces: the fix is in the shared place, so it applies wherever layer.paste and layer.addLayerFile run (desktop, browser, command line, Python, Assistant and MCP). Undo is unchanged: a paste is one undo step, which the new test checks.
Testing
Run locally, crate by crate (the engine tests were filtered, not the whole suite):
cargo test -p rustgis-map --lib: 717 passed, including the new restore_order_reorders_only_the_listed_layers_in_their_places (order, an already-ordered list, empty, unknown and repeated ids, and tile layers).
a_pasted_group_keeps_its_layers_in_drawing_order_around_a_subgroup (the issue's arrangement, a deeper one with a subgroup inside the subgroup, undo of the paste, and a saved group file added back). It failed before the fix with left: ["Extra", "Rivers", "Cities"] right: ["Extra", "Cities", "Rivers"].
a_paste_gathers_a_group_a_foreign_layer_splits_and_goes_in_at_the_top_of_a_group: a layer pasted into a group with its own layers goes in at the group's top; a hand-built clipboard that splits a group is gathered. Its second half fails without the gather step.
a_group_file_with_a_group_split_by_another_layer_adds_it_together: guards the layer file path; it also passes without this change, because the repair after Add Layer File already gathers groups.
The full workspace run is left to pull request CI.
No actionable comments were generated in the recent review.
Walkthrough
The change adds Map::restore_order and uses it during group placement to preserve pasted layer order. Tests cover nested groups, group files, tile placement, and sparse ordering.
Changes: Group layer ordering
Layer / File(s)
Summary
Restore sparse layer order crates/map/src/lib.rs
Map::restore_order reorders listed layers within their existing positions, ignores missing IDs, and handles tile layers when reordering. Tests cover sparse order, no-op inputs, and tile placement.
Apply ordering during group placement crates/engine/src/cmd/layer_copy.rs, crates/engine/src/cmd/group_file.rs, crates/engine/src/tests.rs
Group placement restores pasted layer order and gathers groups outermost first. Engine tests cover nested groups, group-file loading, undo, target-group placement, and separated group layers.
opengeos/RustGIS#2870 — The shared group-file placement path receives the ordering change, which relates to adding saved groups with their subgroups and layers.
Possibly related PRs
opengeos/RustGIS#1102 — Introduces nested layer groups and subtree copy and paste, which this change adjusts for drawing order.
opengeos/RustGIS#3344 — Uses the shared placement path that this change updates for group-file loading.
Suggested reviewers:elpidioassinaturas, giswqs
Merge Risk: Minimal · up to 80176
The change restores the drawing order of pasted groups and group files that contain nested groups. No concrete merge-blocking risk was identified in the supplied evidence.
Pre-merge checks: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Linked Issues check
[#3353] requires that a pasted group keep its copied drawing order (A, B, C) for any nesting, and that group files added back keep it too. The reviewed head calls the new method at the right point. In…
Make the diff of crates/map/src/lib.rs (the restore_order method and its unit test) and of crates/engine/src/tests.rs readable at the reviewed head. Then confirm that restore_order puts the listed layers in the copied order in their…
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title names the fix: Paste Layers keeps a group's drawing order when a subgroup sits between its layers. This matches the main change, which is the layer ordering fix in the shared place path with…
Description check
The description follows the repository template. It has Summary, Testing, UI evidence, and Related issue sections. The Summary explains the bug, the cause, and the fix. The Testing section lists exact…
Out of Scope Changes check
The verified change in crates/engine/src/cmd/layer_copy.rs (place) adds the restore and regather steps, with a comment that ties them to the group-split ordering bug in [#3353]. The other changes …
Full details: Title check
Explanation
The title names the fix: Paste Layers keeps a group's drawing order when a subgroup sits between its layers. This matches the main change, which is the layer ordering fix in the shared place path with the new Map::restore_order method. It also names the affected feature (layer.paste) and the scenario from issue #3353. The title is a single sentence, but at 103 characters it is long and includes an issue number.
Full details: Description check
Explanation
The description follows the repository template. It has Summary, Testing, UI evidence, and Related issue sections. The Summary explains the bug, the cause, and the fix. The Testing section lists exact commands, pass counts, and new tests. The UI evidence section states that no screenshots were taken, and the template allows this when there is no visible UI change, though the template text asks for the 'No visible UI change.' line, which the author replaced with a note. The Related issue section contains Closes #3353. The description is complete.
Full details: Out of Scope Changes check
Explanation
The verified change in crates/engine/src/cmd/layer_copy.rs (place) adds the restore and regather steps, with a comment that ties them to the group-split ordering bug in [#3353]. The other changes listed in the summaries are Map::restore_order in crates/map/src/lib.rs, and regression tests in crates/engine/src/tests.rs and crates/engine/src/cmd/group_file.rs. All of them support the same fix. The PR adds no command, parameter, or interface text, as the PR description states. No change was found that is unrelated to the issue. The map-crate and test changes were not read directly, so this verdict rests on the summaries for those files.
Full details: Linked Issues check
Explanation
[#3353] requires that a pasted group keep its copied drawing order (A, B, C) for any nesting, and that group files added back keep it too. The reviewed head calls the new method at the right point. In crates/engine/src/cmd/layer_copy.rs, place calls m.restore_order(&pasted) after all groups are added, then runs m.gather_group(*g) for each group in outermost-first order. This matches the proposed fix in the issue. The body of Map::restore_order in crates/map/src/lib.rs could not be read. The diff for that file returned that changed blobs are missing from the checkout. The PR summary and the raw summary describe its behavior: it reorders only the listed layers, handles tile layers with release_tiles and settle_tiles, and is covered by a unit test. Those descriptions are not source evidence. The new engine tests (a_pasted_group_keeps_its_layers_in_drawing_order_around_a_subgroup, and the group-file test) were also not run or read. The layer.addLayerFile path uses place, so it inherits the call. That path is not verified by source read.
Resolution
Make the diff of crates/map/src/lib.rs (the restore_order method and its unit test) and of crates/engine/src/tests.rs readable at the reviewed head. Then confirm that restore_order puts the listed layers in the copied order in their current slots, and that the nested-subgroup paste test asserts A, B, C.
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.
A rabbit checks the layers in a row, Pasted groups keep the order they know. Tiles settle when the layers shift, Nested branches hold their place, Then one undo clears the paste.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: 954b8a19-8b64-4867-9c84-a0ec634b2fc6
Commits
Reviewing files that changed from the base of the PR and between 17a145b and 8017668.
Files selected for processing: 4
crates/engine/src/cmd/group_file.rs
crates/engine/src/cmd/layer_copy.rs
crates/engine/src/tests.rs
crates/map/src/lib.rs
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
Scope: 4 files, +202 lines. The change adds Map::restore_order, calls it from the shared place used by layer.paste and group-file Add Layer File, and adds tests. I read the full diff and the surrounding map and tile code. I could not build or run the tests in this environment, so the findings come from reading the code.
Bugs
Tile layers over a listed layer that doesn't move are handed down.restore_order calls release_tiles(ids) with every pasted layer, not only the layers whose slot changes. A tile drawn over a pasted layer that stays put is moved to the layer below. The doc comment and the PR description both say it should keep its place. lift_out and place_layer release only moving layers, so this one is inconsistent with them. Confidence: high that the code does this (traced through pin_tiles and release_tiles, and checked against the existing test fixture: OverC over c would move to b). Medium on reachability: it needs a tile pinned over a pasted layer, which happens when a paste lands above a group's top layer that a tile sits over. I did not build a runnable repro. Inline comment posted with a suggested fix.
Security
None found. No new input parsing, no commands or parameters changed.
Performance
None significant. gather_group runs once per pasted group after add_group has already gathered, which is O(groups × layers). That is fine at realistic layer counts.
Quality
Test leaves a temp file on failure (crates/engine/src/tests.rs:47602). If an earlier step panics, the .rgislyr file stays behind. Inline comment posted.
Test coverage gap: nothing covers a listed layer that stays in place with a tile over it, which is why the bug above passes the existing tests.
AGENTS.md
No rule break found. Checked:
Never crash: no unwrap, expect or indexing in the new non-test code.
Never silent: no data is dropped or approximated.
Wasm: no platform-specific code.
Command surface: no commands or parameters changed, so command-surface.txt is unaffected.
Assets: none added.
Twins checked:
layer.paste and layer.addLayerFile (group file) both go through the shared place, so both get the fix.
qgis.rs import already avoids the bug (it creates all groups empty, then gathers once).
group.add, gp.rs, raster.rs and geolibre.rs each add one group per call, so they don't batch a parent and subgroup.
Opening a project uses tidy_groups, which the PR says is unaffected.
Prior reviews
No existing review threads on this PR, so no earlier concerns were left alone.
Change size
Compared: the whole PR against main (merge base cc06db4 to PR head 8017668).
Commit 8017668 from a fork built, but isn't published until a maintainer adds the preview label (once per commit).
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Paste Layers (
layer.paste) put a copied group's layers in the wrong drawing order when a subgroup sits between the parent's own layers: for P holding A, Q (with B) and C, the paste came in as A, C, B.placeadds the copied groups outermost first, andMap::add_groupgathers the new group's layers right away. When P was added, Q did not exist yet, so only A and C were gathered and B was left below them. Opening a project does not do this, becausetidy_groupsgathers once every group exists.Map::restore_order(ids)puts the listed layers back in that order, in the places they now take in the drawing order; other layers stay where they are. Tile layers drawn over a layer that moves are handed down asrelease_tilesdoes, andsettle_tilesruns after. It does nothing when the layers are already in order.place(crates/engine/src/cmd/layer_copy.rs) calls it with the pasted layers once every group is in, then gathers each pasted group again, outermost first. The second step only matters when a clipboard holds a group's layers apart, which only a hand-built one does; it is a no-op otherwise.layer.addLayerFilefor a group file usesplacetoo, so it gets the same fix. Its repair of the map already gathers groups, so a group file that splits a group was already put together.No command or parameter changes, so
command-surface.txtis unchanged. No new interface text.Surfaces: the fix is in the shared
place, so it applies whereverlayer.pasteandlayer.addLayerFilerun (desktop, browser, command line, Python, Assistant and MCP). Undo is unchanged: a paste is one undo step, which the new test checks.Testing
Run locally, crate by crate (the engine tests were filtered, not the whole suite):
cargo test -p rustgis-map --lib: 717 passed, including the newrestore_order_reorders_only_the_listed_layers_in_their_places(order, an already-ordered list, empty, unknown and repeated ids, and tile layers).cargo test -p rustgis-engine --lib -- a_paste_gathers a_pasted_group_keeps a_group_file paste group_file a_copied_group command_surface hostile_params layer_ undo: 383 passed.cargo clippy -p rustgis-map -p rustgis-engine --all-targets -- -D warningsandcargo fmt --all --check: clean.New tests:
a_pasted_group_keeps_its_layers_in_drawing_order_around_a_subgroup(the issue's arrangement, a deeper one with a subgroup inside the subgroup, undo of the paste, and a saved group file added back). It failed before the fix withleft: ["Extra", "Rivers", "Cities"] right: ["Extra", "Cities", "Rivers"].a_paste_gathers_a_group_a_foreign_layer_splits_and_goes_in_at_the_top_of_a_group: a layer pasted into a group with its own layers goes in at the group's top; a hand-built clipboard that splits a group is gathered. Its second half fails without the gather step.a_group_file_with_a_group_split_by_another_layer_adds_it_together: guards the layer file path; it also passes without this change, because the repair after Add Layer File already gathers groups.The full workspace run is left to pull request CI.
UI evidence
No screenshots taken.
Related issue
Closes #3353
Summary by CodeRabbit