mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03: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:
@ -83,9 +83,9 @@ func (self *ListController) handleLineChange(change int) error {
|
||||
// we're not constantly re-rendering the main view.
|
||||
if before != after {
|
||||
if change == -1 {
|
||||
checkScrollUp(self.context.GetViewTrait(), self.c.UserConfig.Gui.ScrollOffMargin, before, after)
|
||||
checkScrollUp(self.context.GetViewTrait(), self.c.UserConfig, before, after)
|
||||
} else if change == 1 {
|
||||
checkScrollDown(self.context.GetViewTrait(), self.c.UserConfig.Gui.ScrollOffMargin, before, after)
|
||||
checkScrollDown(self.context.GetViewTrait(), self.c.UserConfig, before, after)
|
||||
}
|
||||
|
||||
return self.context.HandleFocus(types.OnFocusOpts{})
|
||||
|
@ -164,7 +164,7 @@ func (self *PatchExplorerController) HandlePrevLine() error {
|
||||
after := self.context.GetState().GetSelectedLineIdx()
|
||||
|
||||
if self.context.GetState().SelectingLine() {
|
||||
checkScrollUp(self.context.GetViewTrait(), self.c.UserConfig.Gui.ScrollOffMargin, before, after)
|
||||
checkScrollUp(self.context.GetViewTrait(), self.c.UserConfig, before, after)
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -176,7 +176,7 @@ func (self *PatchExplorerController) HandleNextLine() error {
|
||||
after := self.context.GetState().GetSelectedLineIdx()
|
||||
|
||||
if self.context.GetState().SelectingLine() {
|
||||
checkScrollDown(self.context.GetViewTrait(), self.c.UserConfig.Gui.ScrollOffMargin, before, after)
|
||||
checkScrollDown(self.context.GetViewTrait(), self.c.UserConfig, before, after)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -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