From a87f3ddba59c3d80c9cbd5a3c837bf4279df47b6 Mon Sep 17 00:00:00 2001 From: Neko Box Coder Date: Sat, 31 Jan 2026 15:10:25 +0000 Subject: [PATCH 1/2] Fixing missing case for handling root node for splitting, fixes #3980 --- internal/views/splits.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/internal/views/splits.go b/internal/views/splits.go index b2a20873f9..7eb8599992 100644 --- a/internal/views/splits.go +++ b/internal/views/splits.go @@ -413,7 +413,7 @@ func (n *Node) HSplit(bottom bool) uint64 { if !n.IsLeaf() { return 0 } - if n.Kind == STUndef { + if n.parent == nil { n.Kind = STVert } if n.Kind == STVert { @@ -429,13 +429,13 @@ func (n *Node) VSplit(right bool) uint64 { if !n.IsLeaf() { return 0 } - if n.Kind == STUndef { + if n.parent == nil { n.Kind = STHoriz } - if n.Kind == STVert { - return n.vVSplit(right) + if n.Kind == STHoriz { + return n.hVSplit(0, right) } - return n.hVSplit(0, right) + return n.vVSplit(right) } // unsplits the child of a split @@ -531,11 +531,17 @@ func (n *Node) flatten() { func (n *Node) String() string { var strf func(n *Node, ident int) string strf = func(n *Node, ident int) string { - marker := "|" + marker := "/" if n.Kind == STHoriz { marker = "-" + } else if n.Kind == STVert { + marker = "|" + } + var parentId uint64 = 0 + if n.parent != nil { + parentId = n.parent.id } - str := fmt.Sprint(strings.Repeat("\t", ident), marker, n.View, n.id) + str := fmt.Sprint(strings.Repeat("\t", ident), marker, n.View, n.id, parentId) if n.IsLeaf() { str += "🍁" } From c554fa708f2608db0cbdb5676b17adcc6bffb7ce Mon Sep 17 00:00:00 2001 From: Neko Box Coder Date: Sat, 31 Jan 2026 21:11:27 +0000 Subject: [PATCH 2/2] Adding special case for root node for flatten() --- internal/views/splits.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/views/splits.go b/internal/views/splits.go index 7eb8599992..88d1f968ed 100644 --- a/internal/views/splits.go +++ b/internal/views/splits.go @@ -483,7 +483,14 @@ 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 return }