Skip to content

Commit

Permalink
Fixed scrolling issue in TreeView. Fixes rivo#796
Browse files Browse the repository at this point in the history
  • Loading branch information
rivo committed Mar 30, 2023
1 parent 281d14d commit 5796b0c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions treeview.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 5796b0c

Please sign in to comment.