Skip to content

Commit a87f3dd

Browse files
Fixing missing case for handling root node for splitting, fixes #3980
1 parent 6a62575 commit a87f3dd

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

internal/views/splits.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ func (n *Node) HSplit(bottom bool) uint64 {
413413
if !n.IsLeaf() {
414414
return 0
415415
}
416-
if n.Kind == STUndef {
416+
if n.parent == nil {
417417
n.Kind = STVert
418418
}
419419
if n.Kind == STVert {
@@ -429,13 +429,13 @@ func (n *Node) VSplit(right bool) uint64 {
429429
if !n.IsLeaf() {
430430
return 0
431431
}
432-
if n.Kind == STUndef {
432+
if n.parent == nil {
433433
n.Kind = STHoriz
434434
}
435-
if n.Kind == STVert {
436-
return n.vVSplit(right)
435+
if n.Kind == STHoriz {
436+
return n.hVSplit(0, right)
437437
}
438-
return n.hVSplit(0, right)
438+
return n.vVSplit(right)
439439
}
440440

441441
// unsplits the child of a split
@@ -531,11 +531,17 @@ func (n *Node) flatten() {
531531
func (n *Node) String() string {
532532
var strf func(n *Node, ident int) string
533533
strf = func(n *Node, ident int) string {
534-
marker := "|"
534+
marker := "/"
535535
if n.Kind == STHoriz {
536536
marker = "-"
537+
} else if n.Kind == STVert {
538+
marker = "|"
539+
}
540+
var parentId uint64 = 0
541+
if n.parent != nil {
542+
parentId = n.parent.id
537543
}
538-
str := fmt.Sprint(strings.Repeat("\t", ident), marker, n.View, n.id)
544+
str := fmt.Sprint(strings.Repeat("\t", ident), marker, n.View, n.id, parentId)
539545
if n.IsLeaf() {
540546
str += "🍁"
541547
}

0 commit comments

Comments
 (0)