summaryrefslogtreecommitdiffstats
path: root/pkg/gui/controllers/list_controller.go
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-05-06 14:02:14 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-05-11 13:23:58 +0200
commite5dd4d311064c2b45dfe3f08a2a4cbf4536404cc (patch)
tree774b5ece77ccd4eacb3fd2223560f7d92e136610 /pkg/gui/controllers/list_controller.go
parent595c7ee73e9d2053fc1cb4ca0b6fd1274852ee9a (diff)
Allow the selected line of a list view to be outside the visible area
I don't see a reason why this restriction to have the selection be always visible was necessary. Removing it has two benefits: 1. Scrolling a list view doesn't change the selection. A common scenario: you look at one of the commits of your current branch; you want to see the how many'th commit this is, but the beginning of the branch is scrolled off the bottom of the commits panel. You scroll down to find the beginning of your branch, but this changes the selection and shows a different commit now - not what you want. 2. It is possible to scroll a panel that is not the current one without changing the focus to it. That's how windows in other GUIs usually behave.
Diffstat (limited to 'pkg/gui/controllers/list_controller.go')
-rw-r--r--pkg/gui/controllers/list_controller.go16
1 files changed, 0 insertions, 16 deletions
diff --git a/pkg/gui/controllers/list_controller.go b/pkg/gui/controllers/list_controller.go
index 0a6de821a..1ca3a1e12 100644
--- a/pkg/gui/controllers/list_controller.go
+++ b/pkg/gui/controllers/list_controller.go
@@ -54,12 +54,6 @@ func (self *ListController) HandleScrollUp() error {
scrollHeight := self.c.UserConfig.Gui.ScrollHeight
self.context.GetViewTrait().ScrollUp(scrollHeight)
- // we only need to do a line change if our line has been pushed out of the viewport, because
- // at the moment much logic depends on the selected line always being visible
- if !self.isSelectedLineInViewPort() {
- return self.handleLineChange(-scrollHeight)
- }
-
return nil
}
@@ -67,19 +61,9 @@ func (self *ListController) HandleScrollDown() error {
scrollHeight := self.c.UserConfig.Gui.ScrollHeight
self.context.GetViewTrait().ScrollDown(scrollHeight)
- if !self.isSelectedLineInViewPort() {
- return self.handleLineChange(scrollHeight)
- }
-
return nil
}
-func (self *ListController) isSelectedLineInViewPort() bool {
- selectedLineIdx := self.context.GetList().GetSelectedLineIdx()
- startIdx, length := self.context.GetViewTrait().ViewPortYBounds()
- return selectedLineIdx >= startIdx && selectedLineIdx < startIdx+length
-}
-
func (self *ListController) scrollHorizontal(scrollFunc func()) error {
scrollFunc()