fn ensure_group_node(node: &mut LayoutNode)Expand description
If node is a leaf (has data), promote it to a group by wrapping its
data in an intermediate child. Mirrors TypeScript addIntermediateNode
in frontend/layout/lib/layoutTree.ts.
After this call:
node.dataisNoneandnode.childrenis non-empty.- The intermediate child receives the node’s ORIGINAL ID so any
frontend reference (e.g.
focusedNodeId) still points at the leaf data after promotion. - The group wrapper gets a fresh UUID, and its flex direction is the reverse of the original leaf’s so the new sibling axis is perpendicular to the parent’s (matches TS layout semantics).
No-op when node is already a group (no data).