diff --git a/treeview.go b/treeview.go index ae937ad..f1f5f00 100644 --- a/treeview.go +++ b/treeview.go @@ -584,9 +584,7 @@ func (t *TreeView) process(drawingAfter bool) { } } } - t.step = 0 t.currentNode = t.nodes[selectedIndex] - t.movement = treeNone // Move selection into viewport. if t.movement != treeScroll { @@ -596,6 +594,11 @@ func (t *TreeView) process(drawingAfter bool) { if selectedIndex < t.offsetY { t.offsetY = selectedIndex } + if t.movement != treeHome && t.movement != treeEnd { + // treeScroll, treeHome, and treeEnd are handled by Draw(). + t.movement = treeNone + t.step = 0 + } } } else { // If selection is not visible or selectable, select the first candidate. @@ -635,7 +638,7 @@ func (t *TreeView) Draw(screen tcell.Screen) { } // Scroll the tree, t.movement is treeNone after process() when there is a - // selection. + // selection, except for treeScroll, treeHome, and treeEnd. x, y, width, height := t.GetInnerRect() switch t.movement { case treeMove, treeScroll: