PanelContainer: bug fix on destroying a panel

This commit fixes a bug where destroying a Panel with a parent of
kind PanelKindSplit... causes the selected to become that split
panel, instead of a child. Now, it chooses the leftmost child of
that parent panel.
This commit is contained in:
Luke I. Wilson 2021-04-07 23:03:20 -05:00
parent 5df772e568
commit 14ba338de9

View File

@ -76,15 +76,24 @@ func (c *PanelContainer) DeleteSelected() Component {
}
if (*p).Left != nil {
// Parent becomes the Left panel
panel := (*p).Left.(*Panel)
(*p).Left = (*panel).Left
(*p).Right = (*panel).Right
(*p).Kind = (*panel).Kind
(*p).SplitAt = (*panel).SplitAt
} else {
(*p).Kind = PanelKindEmpty
}
// Decide what Panel to select next
if !(*p).IsLeaf() { // If the new panel was a split panel...
// Select the leftmost child of it
(*p).EachLeaf(false, func(l *Panel) bool { c.changeSelected(&l); return true })
} else {
c.changeSelected(&p)
}
(*p).UpdateSplits()
} else if c.floatingMode { // Deleting a floating Panel without a parent
c.floating[0] = nil