Repository navigation
reorder_layer: don't mark the image changed when the layer doesn't move (#136) - #189
Conversation
…ve (#136) GIMP's reorder_item marks the image as changed even when the layer stays where it is. Work out where GIMP would put the layer (new_position clamped to its siblings: negative = top, past the end = bottom, counting the layer's group for a grouped layer) and return success without calling reorder_item when that is its current position.
|
No actionable comments were generated in the recent review. Walkthrough
ChangesLayer reorder no-op
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Possibly related PRs
Suggested labels: Suggested reviewers: Merge Risk:
|
Fixes #136.
Problem
reorder_layermarked the image as changed (unsaved-changes marker) even when the layer didn't move. GIMP'sreorder_itemdirties the image whenever it's called, also when the layer stays where it is. Checked live on GIMP 3.2.8: every no-op dirtied the image, for top-level layers, grouped layers, a floating selection, and positions GIMP clamps (-1for the top layer,99for the bottom one).Change
_reorder_layerworks out where GIMP would put the layer:new_positionclamped to the layer's siblings (negative = top, past the end = bottom), counting the siblings in the layer's own group for a grouped layer (since #169). If that isimage.get_item_position(layer), it returns success without callingreorder_item. Real moves, and moves GIMP refuses, behave as before.The tool's description already documents the clamping, so it is unchanged. CHANGELOG entry under
[Unreleased]/ Fixed. No result or parameter changes, so a patch-level fix.Tests
tests/test_reorder_layer.py(new, offline): no-op at each position, clamped no-ops, the only layer, real moves (including clamped ones), a grouped layer counting its group's siblings, and a refused move still failing. Fails 13 subtests onmain, passes here.tests/test_grouped_layers_live.py: 10 no-op moves (grouped, nested, only child, top-level, clamped) must leave the tree unchanged and the image clean. Fails withmain's plugin, passes with this one, on GIMP 3.2.8 (snap).test_layer_position_checks_live.pyandtest_negative_index_live.pystill pass live;uvx ruff@0.15.11 checkand all offline tests pass.Not checked
The comment on #136 asked whether a no-op also cleared the redo history (as an empty undo group does, #148). Plug-ins can't undo or redo on 3.2 (#86), so it wasn't checked; with this change a no-op never reaches GIMP, so it no longer matters here.
Summary by CodeRabbit