Skip to content

Commit 84a6924

Browse files
Fixing resize split can cause crashes when node is root
Fixing resize split can cause crashes when node is root. "Regression" of micro-editor#3983 where ResizeSplit() assumed that the root node always has a single child which aligns to the previous behavior
1 parent e4a92a1 commit 84a6924

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

internal/views/splits.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func (n *Node) hResizeSplit(i int, size int) bool {
186186
// ResizeSplit resizes a certain split to a given size
187187
func (n *Node) ResizeSplit(size int) bool {
188188
// TODO: `size < 0` does not work for some reason
189-
if size <= 0 {
189+
if size <= 0 || n.parent == nil {
190190
return false
191191
}
192192
if len(n.parent.children) <= 1 {
@@ -542,6 +542,10 @@ func (n *Node) flatten() {
542542

543543
// String returns the string form of the node and all children (used for debugging)
544544
func (n *Node) String() string {
545+
if n == nil {
546+
return "Root"
547+
}
548+
545549
var strf func(n *Node, ident int) string
546550
strf = func(n *Node, ident int) string {
547551
marker := ""

0 commit comments

Comments
 (0)