Repository: jesseduffield/lazygit (language: go)

Issue:
Scrolling with the mouse wheel doesn't show past the first 'page' 
**Describe the bug**
When I try to scroll through a diff using the scroll wheel of my mouse (actually using 2-finger scroll on my trackpad, but same difference) it just moves around the first page of the diff but doesn't load any further lines.

**To Reproduce**
Steps to reproduce the behavior:

1. Edit a file with a diff that is longer than the number of lines displayed in lazygit's diff view
2. Scroll diff view with the mouse

**Expected behavior**
It should scroll through the entire diff.

**Screenshots**
I don't have any screenshots on hand, unfortunately (proprietary source code and all that), but if I manage to get some I'll put them here.

**Version info:**
`commit=, build date=, build source=homebrew, version=0.36.0, os=darwin, arch=amd64, git version=2.37.0 (Apple Git-136)`
`git version 2.37.0 (Apple Git-136)

**Additional context**
This started happening when I updated to v0.36.0. My guess as to what's happening is that there was some change to the diff loading that made it only load in the minimal amount it needs to display the shown portion of the diff, and the scroll wheel isn't causing that buffer to update. This guess is based on the fact that when you scroll using the keyboard (select a diff, press enter, then use arrow keys) the size of the scroll bar shrinks as it loads more of the diff.


Discussion / hints:
I noticed this as well, it's a bit of a showstopper bug for me as I rely on the diff information to review my own commits before pushing them, and I can't risk missing part of the changes. It definitely only started happening on v0.36.0, and it seems to happen regardless of the pager used. I was initially using [Delta](https://github.com/dandavison/delta) and thought the bug was related to that, but it happens with the default Git pager as well.
I have the same bug.

Windows 10 / lazygit 0.36.0 / git 2.38.1
524bf83a4a681408c3fb57818f6968cab632e0ae seems bad
[Gui.scrollDownView()](https://github.com/jesseduffield/lazygit/blob/c77df59b9bc5f1922a52770726b8850393728c64/pkg/gui/global_handlers.go#L110)  is not called from [VerticalScrollController.HandleScrollDown](https://github.com/jesseduffield/lazygit/blob/master/pkg/gui/controllers/vertical_scroll_controller.go#L66).

Fix patch:
diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go
index 98a15b3d85c..974080e6704 100644
--- a/pkg/gui/controllers.go
+++ b/pkg/gui/controllers.go
@@ -119,7 +119,7 @@ func (gui *Gui) resetControllers() {
 	undoController := controllers.NewUndoController(common)
 	globalController := controllers.NewGlobalController(common)
 	contextLinesController := controllers.NewContextLinesController(common)
-	verticalScrollControllerFactory := controllers.NewVerticalScrollControllerFactory(common)
+	verticalScrollControllerFactory := controllers.NewVerticalScrollControllerFactory(common, &gui.viewBufferManagerMap)
 
 	branchesController := controllers.NewBranchesController(common)
 	gitFlowController := controllers.NewGitFlowController(common)
diff --git a/pkg/gui/controllers/vertical_scroll_controller.go b/pkg/gui/controllers/vertical_scroll_controller.go
index 3f3e9d177c5..388574df6b7 100644
--- a/pkg/gui/controllers/vertical_scroll_controller.go
+++ b/pkg/gui/controllers/vertical_scroll_controller.go
@@ -3,23 +3,29 @@ package controllers
 import (
 	"github.com/jesseduffield/gocui"
 	"github.com/jesseduffield/lazygit/pkg/gui/types"
+	"github.com/jesseduffield/lazygit/pkg/tasks"
 )
 
 // given we have no fields here, arguably we shouldn't even need this factory
 // struct, but we're maintaining consistency with the other files.
 type VerticalScrollControllerFactory struct {
-	controllerCommon *controllerCommon
+	controllerCommon     *controllerCommon
+	viewBufferManagerMap *map[string]*tasks.ViewBufferManager
 }
 
-func NewVerticalScrollControllerFactory(c *controllerCommon) *VerticalScrollControllerFactory {
-	return &VerticalScrollControllerFactory{controllerCommon: c}
+func NewVerticalScrollControllerFactory(c *controllerCommon, viewBufferManagerMap *map[string]*tasks.ViewBufferManager) *VerticalScrollControllerFactory {
+	return &VerticalScrollControllerFactory{
+		controllerCommon:     c,
+		viewBufferManagerMap: viewBufferManagerMap,
+	}
 }
 
 func (self *VerticalScrollControllerFactory) Create(context types.Context) types.IController {
 	return &VerticalScrollController{
-		baseController:   baseController{},
-		controllerCommon: self.controllerCommon,
-		context:          context,
+		baseController:       baseController{},
+		controllerCommon:     self.controllerCommon,
+		context:              context,
+		viewBufferManagerMap: self.viewBufferManagerMap,
 	}
 }
 
@@ -27,7 +33,8 @@ type VerticalScrollController struct {
 	baseController
 	*controllerCommon
 
-	context types.Context
+	context              types.Context
+	viewBufferManagerMap *map[string]*tasks.ViewBufferManager
 }
 
 func (self *VerticalScrollController) Context() types.Context {
@@ -64,7 +71,12 @@ func (self *VerticalScrollController) HandleScrollUp() error {
 }
 
 func (self *VerticalScrollController) HandleScrollDown() error {
-	self.context.GetViewTrait().ScrollDown(self.c.UserConfig.Gui.ScrollHeight)
+	scrollHeight := self.c.UserConfig.Gui.ScrollHeight
+	self.context.GetViewTrait().ScrollDown(scrollHeight)
+
+	if manager, ok := (*self.viewBufferManagerMap)[self.context.GetViewName()]; ok {
+		manager.ReadLines(scrollHeight)
+	}
 
 	return nil
 }


Test patch: