mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-23 22:24:51 +02:00
Pass UserConfig to checkScrollUp/Down instead of just the scrollOffMargin
This will allow us to add a scrollOffEnabled config and have the functions respect it without changes to clients.
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
)
|
||||
|
||||
// To be called after pressing up-arrow; checks whether the cursor entered the
|
||||
// top scroll-off margin, and so the view needs to be scrolled up one line
|
||||
func checkScrollUp(view types.IViewTrait, scrollOffMargin int, lineIdxBefore int, lineIdxAfter int) {
|
||||
func checkScrollUp(view types.IViewTrait, userConfig *config.UserConfig, lineIdxBefore int, lineIdxAfter int) {
|
||||
viewPortStart, viewPortHeight := view.ViewPortYBounds()
|
||||
|
||||
linesToScroll := calculateLinesToScrollUp(
|
||||
viewPortStart, viewPortHeight, scrollOffMargin, lineIdxBefore, lineIdxAfter)
|
||||
viewPortStart, viewPortHeight, userConfig.Gui.ScrollOffMargin, lineIdxBefore, lineIdxAfter)
|
||||
if linesToScroll != 0 {
|
||||
view.ScrollUp(linesToScroll)
|
||||
}
|
||||
@@ -19,11 +20,11 @@ func checkScrollUp(view types.IViewTrait, scrollOffMargin int, lineIdxBefore int
|
||||
|
||||
// To be called after pressing down-arrow; checks whether the cursor entered the
|
||||
// bottom scroll-off margin, and so the view needs to be scrolled down one line
|
||||
func checkScrollDown(view types.IViewTrait, scrollOffMargin int, lineIdxBefore int, lineIdxAfter int) {
|
||||
func checkScrollDown(view types.IViewTrait, userConfig *config.UserConfig, lineIdxBefore int, lineIdxAfter int) {
|
||||
viewPortStart, viewPortHeight := view.ViewPortYBounds()
|
||||
|
||||
linesToScroll := calculateLinesToScrollDown(
|
||||
viewPortStart, viewPortHeight, scrollOffMargin, lineIdxBefore, lineIdxAfter)
|
||||
viewPortStart, viewPortHeight, userConfig.Gui.ScrollOffMargin, lineIdxBefore, lineIdxAfter)
|
||||
if linesToScroll != 0 {
|
||||
view.ScrollDown(linesToScroll)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user