From 7bdba1abe4ffa9c53f04204fed82a8ac34e7d4a3 Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Tue, 20 Dec 2022 22:25:49 +0900 Subject: [PATCH] fix(#2309): fix diff scroll --- pkg/gui/controllers.go | 2 +- .../controllers/vertical_scroll_controller.go | 28 +++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go index 98a15b3d8..974080e67 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 3f3e9d177..388574df6 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 }