From 234b80b79fb17ee042e275c970275584d2975b61 Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Sun, 19 May 2019 19:47:06 -0400 Subject: [PATCH] Fix bug where going to the next when there wasn't a direct parent wouldn't work --- tree.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tree.go b/tree.go index d6fcc8f..2e7cae2 100644 --- a/tree.go +++ b/tree.go @@ -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 + } } }