Fix bug where going to the next when there wasn't a direct parent wouldn't work

This commit is contained in:
Nick Krichevsky 2019-05-19 19:47:06 -04:00
parent 2ef204db6f
commit 234b80b79f

13
tree.go
View file

@ -61,9 +61,16 @@ func (tree *TreeWidget) SelectNext() {
tree.selectedNode = tree.selectedNode.children[0]
} else if tree.selectedNode.next != nil {
tree.selectedNode = tree.selectedNode.next
} else if tree.selectedNode.next == nil && tree.selectedNode.parent != nil && tree.selectedNode.parent.next != nil {
// Go up to the next adjacent node to a parent
tree.selectedNode = tree.selectedNode.parent.next
} else if tree.selectedNode.next == nil && tree.selectedNode.parent != nil {
cursorNode := tree.selectedNode.parent
// Go up to the next adjacent node to the first parent node with another node adjacent to it.
for cursorNode != nil {
if cursorNode.next != nil {
tree.selectedNode = cursorNode.next
return
}
cursorNode = cursorNode.parent
}
}
}