Skip to content

fix(postprocess): suppress nested moves under demoted ancestor moves - #171

Merged
HarshK97 merged 1 commit into
mainfrom
fix/postprocess-suppress-demoted-nested-moves
Sep 20, 2026
Merged

HarshK97 merged 1 commit into
mainfrom
fix/postprocess-suppress-demoted-nested-moves

Conversation

@HarshK97

Copy link
Copy Markdown
Owner

Problem

  1. When an ancestor container move gets demoted to a subtree Delete + Insert (like a distant cross-scope move), Move actions on its descendant nodes were still surviving in Pass 2, causing conflicting move highlights inside an already-deleted subtree.
  2. In Pass 2, normalizeMovesByStructure was re-running shouldDemoteMove while demoteMoveToDelIns was actively mutating the node mappings, making demotion decisions dependent on map mutation order.

What Changed

  • Recorded demoted moves in a toDemote map and their descendants in a demotedDescendants set during Pass 1, so Pass 2 never re-evaluates demotion checks against a mutating mapping.
  • Skipped nested Move actions in Pass 2 if the node is in demotedDescendants, since the ancestor is already replaced as a full subtree Delete + Insert.
  • Flattened the action loop in Pass 2 into an early nil guard and a clean switch a.Type.
  • Added a unit test in internal/postprocess/normalize_test.go verifying that nested moves under a demoted ancestor move are suppressed and only the ancestor's Delete + Insert survive.

- Evict and suppress nested move actions whose ancestor move was demoted to delete/insert in normalizeMovesByStructure
- Prevent ms.Src()[a.Node] == nil fallback from resurrecting descendant moves whose mappings were stripped
- Add unit test verifying nested move suppression inside demoted ancestor containers
@HarshK97
HarshK97 force-pushed the fix/postprocess-suppress-demoted-nested-moves branch from dda9dfc to c43c57e Compare September 20, 2026 17:17
@HarshK97
HarshK97 merged commit e806b38 into main Sep 20, 2026
17 checks passed
@HarshK97
HarshK97 deleted the fix/postprocess-suppress-demoted-nested-moves branch September 20, 2026 17:21
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.

1 participant