Skip to content

[BUG?] reparent_from_id_append() does not set new parent for the migrating children that have their own children. #44

Open
@digitalcortex

Description

@digitalcortex

Scope: node_mut.reparent_from_id_append(...)
Observation: reparented child that contains own children retains the link to the old parent.
Expected: all reparented children get "parent" link updated to the new parent regardless of whether they have own children.
Library version: ego-tree = "0.10.0"

I'm writing an algorithm that is merging the contents of the multiple consequent matching siblings into one node. In order to transfer children from one node to another node I'm calling reparent_from_id_append() on the future parent and passing sibling's id as an argument.

Example.

Tree before merging:

Heading2 (NodeId(7))
    Text (NodeId(8)): "Self-Managed Cyprus\n\t\t\t\t\t\t\t\t\t\t\tLTD"
Heading2 (NodeId(9))
    Text (NodeId(10)): "from "
    Bold (NodeId(11))
        Text (NodeId(12)): "€ 1070"
    Text (NodeId(13)): "\n\t\t\t\t\t\t\t\t\t\t\tplus VAT"
Heading2 (NodeId(14))
    Link (NodeId(15))
        Text (NodeId(16)): "Order now"

Expected tree after merging:

Heading2 (NodeId(7))
    Text (NodeId(8)): "Self-Managed Cyprus\n\t\t\t\t\t\t\t\t\t\t\tLTD"
    Text (NodeId(10)): "from "
    Bold (NodeId(11))
        Text (NodeId(12)): "€ 1070"
    Text (NodeId(13)): "\n\t\t\t\t\t\t\t\t\t\t\tplus VAT"
    Link (NodeId(15))
        Text (NodeId(16)): "Order now"

In this example I'm having issue with Node 11: it is retaining a reference to the old parent Node 9 while it should be pointing at a new parent Node 7. I verified that by migrated_child.ancestors() method and migrated_child.parent.

It does not seem like an intended behavior because Node 7 starts having Node 11 among its children (as expected) but Node 11 doesn't seem to know about it and still remembers old parent Node 9 (not expected).

Could anyone from maintainers please provide some information on this issue I'm having?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions