Skip to content

Commit 9e89afb

Browse files
Merge branch 'ChainedParentsFix' into dev
2 parents 2c3265b + ec4ca05 commit 9e89afb

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
> - [Add the ability lock settings.json and bindings.json for plugins #3618](https://github.com/zyedidia/micro/pull/3618)
1818
> - [Adding error screen for lua functions running in status line #3691](https://github.com/zyedidia/micro/pull/3691)
1919
> - [Adding lua function to use result of RunBackgroundShell #3692](https://github.com/zyedidia/micro/pull/3692)
20+
> - [Fix unable to perform proportional resize caused by chained parents after quiting a nested HSplit inside a VSplit #3708](https://github.com/zyedidia/micro/pull/3708)
2021
>
2122
> To see the diff between this and upstream master, click [here](https://github.com/zyedidia/micro/compare/master...Neko-Box-Coder:micro-dev:dev)
2223

internal/views/splits.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,32 @@ func (n *Node) Unsplit() bool {
479479
if n.parent.IsLeaf() {
480480
return n.parent.Unsplit()
481481
}
482+
483+
n.parent.simplify()
482484
return true
483485
}
484486

487+
// Simplify removes unnecessary chained parents
488+
func (n *Node) simplify() {
489+
if n.parent == nil || len(n.children) != 1 {
490+
return
491+
}
492+
493+
ind := 0
494+
for i, c := range n.parent.children {
495+
if c.id == n.id {
496+
ind = i
497+
}
498+
}
499+
500+
parent := n.parent
501+
kind := n.Kind
502+
parent.children[ind] = n.children[0]
503+
parent.children[ind].parent = parent
504+
parent.children[ind].Kind = kind
505+
parent.simplify()
506+
}
507+
485508
// String returns the string form of the node and all children (used for debugging)
486509
func (n *Node) String() string {
487510
var strf func(n *Node, ident int) string

0 commit comments

Comments
 (0)