Skip to content

Commit ce0a1ce

Browse files
committed
When pressing up or down, scroll selection into view if it is outside, even if it didn't change
We have this logic to avoid constantly rerendering the main view when hitting up-arrow when you are already at the top of the list. That's good, but we do want to scroll the selection into view if it is outside and you hit up or down, no matter if it changed.
1 parent e88fdc0 commit ce0a1ce

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/gui/controllers/list_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ func (self *ListController) handleLineChangeAux(f func(int), change int) error {
117117

118118
if cursorMoved || rangeBefore != rangeAfter {
119119
self.context.HandleFocus(types.OnFocusOpts{ScrollSelectionIntoView: true})
120+
} else {
121+
// If the selection did not change (because, for example, we are at the top of the list and
122+
// press up), we still want to ensure that the selection is visible. This is useful after
123+
// scrolling the selection out of view with the mouse.
124+
self.context.FocusLine(true)
120125
}
121126

122127
return nil

0 commit comments

Comments
 (0)