Fix multi-root traversal
parent
456f817d67
commit
350a24badd
10
tree.go
10
tree.go
|
@ -49,10 +49,14 @@ func (tree *TreeWidget) Draw(buffer *termui.Buffer) {
|
|||
|
||||
// AddRootNode adds a new top-level node to the tree
|
||||
func (tree *TreeWidget) AddRootNode(node *Node) {
|
||||
tree.rootNodes = append(tree.rootNodes, node)
|
||||
if len(tree.rootNodes) == 1 {
|
||||
tree.selectedNode = node.children[0]
|
||||
if len(tree.rootNodes) > 0 {
|
||||
node.prev = tree.rootNodes[len(tree.rootNodes)-1]
|
||||
node.prev.next = node
|
||||
} else if len(tree.rootNodes) == 0 {
|
||||
// If this is our first node, then we need to mark this as the current node
|
||||
tree.selectedNode = node
|
||||
}
|
||||
tree.rootNodes = append(tree.rootNodes, node)
|
||||
node.setTree(tree)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue