Skip to content

Commit

Permalink
fix(#2309): fix diff scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryooooooga committed Dec 20, 2022
1 parent 43b5a80 commit 7bdba1a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/gui/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 20 additions & 8 deletions pkg/gui/controllers/vertical_scroll_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,38 @@ 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,
}
}

type VerticalScrollController struct {
baseController
*controllerCommon

context types.Context
context types.Context
viewBufferManagerMap *map[string]*tasks.ViewBufferManager
}

func (self *VerticalScrollController) Context() types.Context {
Expand Down Expand Up @@ -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
}

0 comments on commit 7bdba1a

Please sign in to comment.