We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f4d62a4 commit 4cb5201Copy full SHA for 4cb5201
1 file changed
internal/views/splits.go
@@ -479,9 +479,31 @@ func (n *Node) Unsplit() bool {
479
if n.parent.IsLeaf() {
480
return n.parent.Unsplit()
481
}
482
+
483
+ n.parent.Simplify()
484
return true
485
486
487
+// Simplify removes unnecessary chained parents
488
+func (n *Node) Simplify() {
489
+ if n.parent == nil {
490
+ return
491
+ }
492
493
+ ind := 0
494
+ if len(n.children) == 1 {
495
+ for i, c := range n.parent.children {
496
+ if c.id == n.id {
497
+ ind = i
498
499
500
501
502
+ parent := n.parent
503
+ n.parent.children[ind] = n.children[0]
504
+ parent.Simplify()
505
+}
506
507
// String returns the string form of the node and all children (used for debugging)
508
func (n *Node) String() string {
509
var strf func(n *Node, ident int) string
0 commit comments