diff --git a/internal/views/splits.go b/internal/views/splits.go index 1ee8d72f..d310db21 100644 --- a/internal/views/splits.go +++ b/internal/views/splits.go @@ -483,7 +483,20 @@ func (n *Node) Unsplit() bool { // flattens the tree by removing unnecessary intermediate parents that have only one child // and handles the side effect of it func (n *Node) flatten() { - if n.parent == nil || len(n.children) != 1 { + if len(n.children) != 1 { + return + } + + // Special case for root node + if n.parent == nil { + *n = *n.children[0] + n.parent = nil + for _, c := range n.children { + c.parent = n + } + if len(n.children) == 0 { + n.Kind = STUndef + } return }