Skip to content

Commit c8a121f

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

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

internal/views/splits.go

Lines changed: 11 additions & 6 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
@@ -535,7 +535,12 @@ func (n *Node) String() string {
535535
if n.Kind == STHoriz {
536536
marker = "-"
537537
}
538-
str := fmt.Sprint(strings.Repeat("\t", ident), marker, n.View, n.id)
538+
var str string
539+
if n.parent != nil {
540+
str = fmt.Sprint(strings.Repeat("\t", ident), marker, n.View, n.id, n.parent.id)
541+
} else {
542+
str = fmt.Sprint(strings.Repeat("\t", ident), marker, n.View, n.id, " root")
543+
}
539544
if n.IsLeaf() {
540545
str += "🍁"
541546
}

0 commit comments

Comments
 (0)